forked from orangepi-xunlong/wiringOP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·300 lines (270 loc) · 8.11 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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#!/bin/bash -e
# build
# Simple wiringPi build and install script
#
# Copyright (c) 2012-2015 Gordon Henderson
#################################################################################
# This file is part of wiringPi:
# A "wiring" library for the Raspberry Pi
#
# wiringPi is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# wiringPi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
#################################################################################
#
# wiringPi is designed to run on a Raspberry Pi only.
# However if you're clever enough to actually look at this script to
# see why it's not building for you, then good luck.
#
# To everyone else: Stop using cheap alternatives. Support the
# Raspberry Pi Foundation as they're the only ones putting money
# back into education!
#################################################################################
check_make_ok() {
if [ $? != 0 ]; then
echo ""
echo "Make Failed..."
echo "Please check the messages and fix any problems. If you're still stuck,"
echo "then please email all the output and as many details as you can to"
echo " [email protected]"
echo ""
exit 1
fi
}
select_boards()
{
local cnt=0
local choice
local call=${1}
boards=("orangepir1"
"orangepizero"
"orangepizero-lts"
"orangepipc"
"orangepipch5"
"orangepipcplus"
"orangepiplus2e"
"orangepione"
"orangepioneh5"
"orangepilite"
"orangepiplus"
"orangepizeroplus2h3"
"orangepizeroplus"
"orangepipc2"
"orangepiprime"
"orangepizeroplus2h5"
"orangepiwin"
"orangepiwinplus"
"orangepi3"
"orangepi3-lts"
"orangepilite2"
"orangepioneplus"
"orangepi4"
"orangepi4-lts"
"orangepirk3399"
"orangepi800"
"orangepizero2"
"orangepizero2-lts"
"orangepizero2-b"
"orangepizero3"
"orangepir1plus-lts"
"orangepir1plus")
if [[ -f /etc/orangepi-release ]]; then
source /etc/orangepi-release
elif [[ -f /etc/armbian-release ]]; then
source /etc/armbian-release
[[ $BOARD == orangepi-r1 ]] && BOARD=orangepir1
[[ $BOARD == orangepi-rk3399 ]] && BOARD=orangepirk3399
[[ $BOARD == orangepizeroplus2-h3 ]] && BOARD=orangepizeroplus2h3
[[ $BOARD == orangepizeroplus2-h5 ]] && BOARD=orangepizeroplus2h5
else
printf "All available boards:\n"
for var in ${boards[@]} ; do
printf "%4d. %s\n" $cnt ${boards[$cnt]}
((cnt+=1))
done
while true ; do
read -p "Choice: " choice
if [ -z "${choice}" ] ; then
continue
fi
if [ -z "${choice//[0-9]/}" ] ; then
if [ $choice -ge 0 -a $choice -lt $cnt ] ; then
export BOARD="${boards[$choice]}"
break
fi
fi
printf "Invalid input ...\n"
done
fi
[[ $BOARD == orangepir1 ]] && BOARD=orangepir1-h2
[[ $BOARD == orangepizero ]] && BOARD=orangepizero-h2
[[ $BOARD == orangepizero-lts ]] && BOARD=orangepizero-h2
[[ $BOARD == orangepipc ]] && BOARD=orangepipc-h3
[[ $BOARD == orangepipch5 ]] && BOARD=orangepipc-h3
[[ $BOARD == orangepipcplus ]] && BOARD=orangepipcplus-h3
[[ $BOARD == orangepiplus2e ]] && BOARD=orangepiplus2e-h3
[[ $BOARD == orangepione ]] && BOARD=orangepione-h3
[[ $BOARD == orangepioneh5 ]] && BOARD=orangepione-h3
[[ $BOARD == orangepilite ]] && BOARD=orangepilite-h3
[[ $BOARD == orangepiplus ]] && BOARD=orangepiplus-h3
[[ $BOARD == orangepizeroplus ]] && BOARD=orangepizeroplus-h5
[[ $BOARD == orangepipc2 ]] && BOARD=orangepipc2-h5
[[ $BOARD == orangepiprime ]] && BOARD=orangepiprime-h5
[[ $BOARD == orangepiwin ]] && BOARD=orangepiwin-a64
[[ $BOARD == orangepiwinplus ]] && BOARD=orangepiwinplus-a64
[[ $BOARD == orangepi3 ]] && BOARD=orangepi3-h6
[[ $BOARD == orangepi3-lts ]] && BOARD=orangepi3-h6
[[ $BOARD == orangepilite2 ]] && BOARD=orangepilite2-h6
[[ $BOARD == orangepioneplus ]] && BOARD=orangepioneplus-h6
[[ $BOARD == orangepizero2 ]] && BOARD=orangepizero2-h616
[[ $BOARD == orangepizero2-lts ]] && BOARD=orangepizero2-h616
[[ $BOARD == orangepizero2-b ]] && BOARD=orangepizero2-h616
[[ $BOARD == orangepizero3 ]] && BOARD=orangepizero2-h616
[[ $BOARD == orangepir1plus ]] && BOARD=orangepir1plus-rk3328
[[ $BOARD == orangepir1plus-lts ]] && BOARD=orangepir1plus-rk3328
export BOARD="${BOARD}"
}
sudo=${WIRINGPI_SUDO-sudo}
if [ x$1 = "xclean" ]; then
cd wiringPi
echo -n "wiringPi: " ; make clean
cd ../devLib
echo -n "DevLib: " ; make clean
cd ../gpio
echo -n "gpio: " ; make clean
cd ../examples
echo -n "Examples: " ; make clean
cd Gertboard
echo -n "Gertboard: " ; make clean
cd ../PiFace
echo -n "PiFace: " ; make clean
cd ../q2w
echo -n "Quick2Wire: " ; make clean
cd ../PiGlow
echo -n "PiGlow: " ; make clean
cd ../scrollPhat
echo -n "scrollPhat: " ; make clean
cd ../..
echo -n "Deb: " ; rm -f debian-template/wiringpi*.deb
echo
exit
fi
if [ x$1 = "xuninstall" ]; then
cd wiringPi
echo -n "wiringPi: " ; $sudo make uninstall
cd ../devLib
echo -n "DevLib: " ; $sudo make uninstall
cd ../gpio
echo -n "gpio: " ; $sudo make uninstall
exit
fi
# Only if you know what you're doing!
if [ x$1 = "xdebian" ]; then
here=`pwd`
echo "removing old libs"
cd debian-template/wiringPi
rm -rf usr
echo "building wiringPi"
cd $here/wiringPi
make install-deb
echo "building devLib"
cd $here/devLib
make install-deb INCLUDE='-I. -I../wiringPi'
echo "building gpio"
cd $here/gpio
make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib
echo "Building deb package"
cd $here/debian-template
fakeroot dpkg-deb --build wiringPi
mv wiringPi.deb wiringpi-`cat $here/VERSION`-1.deb
exit
fi
if [ x$1 != "x" ]; then
echo "Usage: $0 [clean | uninstall]"
exit 1
fi
select_boards
echo "wiringPi Build script"
echo "====================="
echo
hardware=`fgrep Hardware /proc/cpuinfo | head -1 | awk '{ print $3 }'`
# if [ x$hardware != "xBCM2708" ]; then
# echo ""
# echo " +------------------------------------------------------------+"
# echo " | wiringPi is designed to run on the Raspberry Pi only. |"
# echo " | This processor does not appear to be a Raspberry Pi. |"
# echo " +------------------------------------------------------------+"
# echo " | In the unlikely event that you think it is a Raspberry Pi, |"
# echo " | then please accept my apologies and email the contents of |"
# echo " | /proc/cpuinfo to [email protected]. |"
# echo " | - Thanks, Gordon |"
# echo " +------------------------------------------------------------+"
# echo ""
# exit 1
# fi
echo
echo "WiringPi Library"
cd wiringPi
$sudo make uninstall
if [ x$1 = "xstatic" ]; then
make -j5 static
check_make_ok
$sudo make install-static
else
make -j5
check_make_ok
$sudo make install
fi
check_make_ok
echo
echo "WiringPi Devices Library"
cd ../devLib
$sudo make uninstall
if [ x$1 = "xstatic" ]; then
make -j5 static
check_make_ok
$sudo make install-static
else
make -j5
check_make_ok
$sudo make install
fi
check_make_ok
echo
echo "GPIO Utility"
cd ../gpio
make -j5
check_make_ok
$sudo make install
check_make_ok
# echo
# echo "wiringPi Daemon"
# cd ../wiringPiD
# make -j5
# check_make_ok
# $sudo make install
# check_make_ok
# echo
# echo "Examples"
# cd ../examples
# make
# cd ..
echo
echo All Done.
echo ""
echo "NOTE: To compile programs with wiringPi, you need to add:"
echo " -lwiringPi"
echo " to your compile line(s) To use the Gertboard, MaxDetect, etc."
echo " code (the devLib), you need to also add:"
echo " -lwiringPiDev"
echo " to your compile line(s)."
echo ""