Statistics
| Branch: | Revision:

ddr4s / fw / wiringPi / build @ 32:cadb9025f1e0

History | View | Annotate | Download (5.04 KB)

1
#!/bin/sh -e
2

    
3
# build
4
#	Simple wiringPi build and install script
5
#
6
#	Copyright (c) 2012-2015 Gordon Henderson
7
#################################################################################
8
# This file is part of wiringPi:
9
#	A "wiring" library for the Raspberry Pi
10
#
11
#    wiringPi is free software: you can redistribute it and/or modify
12
#    it under the terms of the GNU Lesser General Public License as published by
13
#    the Free Software Foundation, either version 3 of the License, or
14
#    (at your option) any later version.
15
#
16
#    wiringPi is distributed in the hope that it will be useful,
17
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
18
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
#    GNU Lesser General Public License for more details.
20
#
21
#    You should have received a copy of the GNU Lesser General Public License
22
#    along with wiringPi.  If not, see <http://www.gnu.org/licenses/>.
23
#################################################################################
24
#
25
# wiringPi is designed to run on a Raspberry Pi only.
26
#	However if you're clever enough to actually look at this script to
27
#	see why it's not building for you, then good luck.
28
#
29
#	To everyone else: Stop using cheap alternatives. Support the
30
#	Raspberry Pi Foundation	as they're the only ones putting money
31
#	back into education!
32
#################################################################################
33

    
34
check_make_ok() {
35
  if [ $? != 0 ]; then
36
    echo ""
37
    echo "Make Failed..."
38
    echo "Please check the messages and fix any problems. If you're still stuck,"
39
    echo "then please email all the output and as many details as you can to"
40
    echo "  projects@drogon.net"
41
    echo ""
42
    exit 1
43
  fi
44
}
45

    
46
sudo=${WIRINGPI_SUDO-sudo}
47

    
48
if [ x$1 = "xclean" ]; then
49
  cd wiringPi
50
  echo -n "wiringPi:   "	; make clean
51
  cd ../devLib
52
  echo -n "DevLib:     "	; make clean
53
  cd ../gpio
54
  echo -n "gpio:       "	; make clean
55
  cd ../examples
56
  echo -n "Examples:   "	; make clean
57
  cd Gertboard
58
  echo -n "Gertboard:  "	; make clean
59
  cd ../PiFace
60
  echo -n "PiFace:     "	; make clean
61
  cd ../q2w
62
  echo -n "Quick2Wire: "	; make clean
63
  cd ../PiGlow
64
  echo -n "PiGlow:     "	; make clean
65
  cd ../scrollPhat
66
  echo -n "scrollPhat: "	; make clean
67
  cd ../..
68
  echo -n "Deb: " ; rm  -f debian-template/wiringpi*.deb
69
  echo
70
  exit
71
fi
72

    
73
if [ x$1 = "xuninstall" ]; then
74
  cd wiringPi
75
  echo -n "wiringPi: " ; $sudo make uninstall
76
  cd ../devLib
77
  echo -n "DevLib:   " ; $sudo make uninstall
78
  cd ../gpio
79
  echo -n "gpio:     " ; $sudo make uninstall
80
  exit
81
fi
82

    
83
# Only if you know what you're doing!
84

    
85
if [ x$1 = "xdebian" ]; then
86
  here=`pwd`
87
  cd debian-template/wiringPi
88
  rm -rf usr
89
  cd $here/wiringPi
90
  make install-deb
91
  cd $here/devLib
92
  make install-deb INCLUDE='-I. -I../wiringPi'
93
  cd $here/gpio
94
  make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib
95
  cd $here/debian-template
96
  fakeroot dpkg-deb --build wiringPi
97
  mv wiringPi.deb  wiringpi-`cat $here/VERSION`-1.deb
98
  exit
99
fi
100

    
101
if [ x$1 != "x" ]; then
102
  echo "Usage: $0 [clean | uninstall]"
103
  exit 1
104
fi
105

    
106
  echo "wiringPi Build script"
107
  echo "====================="
108
  echo
109

    
110
  hardware=`fgrep Hardware /proc/cpuinfo | head -1 | awk '{ print $3 }'`
111

    
112
#  if [ x$hardware != "xBCM2708" ]; then
113
#    echo ""
114
#    echo "   +------------------------------------------------------------+"
115
#    echo "   |   wiringPi is designed to run on the Raspberry Pi only.    |"
116
#    echo "   |   This processor does not appear to be a Raspberry Pi.     |"
117
#    echo "   +------------------------------------------------------------+"
118
#    echo "   | In the unlikely event that you think it is a Raspberry Pi, |"
119
#    echo "   | then please accept my apologies and email the contents of  |"
120
#    echo "   | /proc/cpuinfo to projects@drogon.net.                      |"
121
#    echo "   |    - Thanks, Gordon                                        |"
122
#    echo "   +------------------------------------------------------------+"
123
#    echo ""
124
#    exit 1
125
#  fi
126

    
127

    
128
  echo
129
  echo "WiringPi Library"
130
  cd wiringPi
131
  $sudo make uninstall
132
  if [ x$1 = "xstatic" ]; then
133
    make -j5 static
134
    check_make_ok
135
    $sudo make install-static
136
  else
137
    make -j5
138
    check_make_ok
139
    $sudo make install
140
  fi
141
  check_make_ok
142

    
143
  echo
144
  echo "WiringPi Devices Library"
145
  cd ../devLib
146
  $sudo make uninstall
147
  if [ x$1 = "xstatic" ]; then
148
    make -j5 static
149
    check_make_ok
150
    $sudo make install-static
151
  else
152
    make -j5
153
    check_make_ok
154
    $sudo make install
155
  fi
156
  check_make_ok
157

    
158
  echo
159
  echo "GPIO Utility"
160
  cd ../gpio
161
  make -j5
162
  check_make_ok
163
  $sudo make install
164
  check_make_ok
165

    
166
# echo
167
# echo "wiringPi Daemon"
168
# cd ../wiringPiD
169
# make -j5
170
# check_make_ok
171
# $sudo make install
172
# check_make_ok
173

    
174
# echo
175
# echo "Examples"
176
# cd ../examples
177
# make
178
# cd ..
179

    
180
echo
181
echo All Done.
182
echo ""
183
echo "NOTE: To compile programs with wiringPi, you need to add:"
184
echo "    -lwiringPi"
185
echo "  to your compile line(s) To use the Gertboard, MaxDetect, etc."
186
echo "  code (the devLib), you need to also add:"
187
echo "    -lwiringPiDev"
188
echo "  to your compile line(s)."
189
echo ""