chiark / gitweb /
Debian build: Fix .so symlinks
[wiringPi.git] / build
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 #       Wiring Compatable 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   exit
66 fi
67
68 if [ x$1 = "xuninstall" ]; then
69   cd wiringPi
70   echo -n "wiringPi: " ; $sudo make uninstall
71   cd ../devLib
72   echo -n "DevLib:   " ; $sudo make uninstall
73   cd ../gpio
74   echo -n "gpio:     " ; $sudo make uninstall
75   exit
76 fi
77
78 if [ x$1 = "xdebian" ]; then
79   if ! dpkg-checkbuilddeps; then
80     $sudo apt-get install build-essential debhelper fakeroot
81     dpkg-checkbuilddeps
82   fi
83   dpkg-buildpackage -b -us -uc -rfakeroot
84   exit
85 fi
86
87 # Only if you know what you're doing!
88
89 if [ x$1 = "xdebian-template" ]; then
90   # produces a single .deb in a nonstandard way from debian-template/
91   here=`pwd`
92   cd debian-template/wiringPi
93   rm -rf usr
94   cd $here/wiringPi
95   make install-deb
96   cd $here/devLib
97   make install-deb INCLUDE='-I. -I../wiringPi'
98   cd $here/gpio
99   make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib
100   cd $here/debian-template
101   fakeroot dpkg-deb --build wiringPi
102   mv wiringPi.deb  wiringpi-`cat $here/VERSION`-1.deb
103   exit
104 fi
105
106 if [ x$1 != "x" ]; then
107   echo "Usage: $0 [clean | uninstall]"
108   exit 1
109 fi
110
111   echo "wiringPi Build script"
112   echo "====================="
113   echo
114
115   hardware=`fgrep Hardware /proc/cpuinfo | head -1 | awk '{ print $3 }'`
116
117 #  if [ x$hardware != "xBCM2708" ]; then
118 #    echo ""
119 #    echo "   +------------------------------------------------------------+"
120 #    echo "   |   wiringPi is designed to run on the Raspberry Pi only.    |"
121 #    echo "   |   This processor does not appear to be a Raspberry Pi.     |"
122 #    echo "   +------------------------------------------------------------+"
123 #    echo "   | In the unlikely event that you think it is a Raspberry Pi, |"
124 #    echo "   | then please accept my apologies and email the contents of  |"
125 #    echo "   | /proc/cpuinfo to projects@drogon.net.                      |"
126 #    echo "   |    - Thanks, Gordon                                        |"
127 #    echo "   +------------------------------------------------------------+"
128 #    echo ""
129 #    exit 1
130 #  fi
131
132
133   echo
134   echo "WiringPi Library"
135   cd wiringPi
136   $sudo make uninstall
137   if [ x$1 = "xstatic" ]; then
138     make -j5 static
139     check_make_ok
140     $sudo make install-static
141   else
142     make -j5
143     check_make_ok
144     $sudo make install
145   fi
146   check_make_ok
147
148   echo
149   echo "WiringPi Devices Library"
150   cd ../devLib
151   $sudo make uninstall
152   if [ x$1 = "xstatic" ]; then
153     make -j5 static
154     check_make_ok
155     $sudo make install-static
156   else
157     make -j5
158     check_make_ok
159     $sudo make install
160   fi
161   check_make_ok
162
163   echo
164   echo "GPIO Utility"
165   cd ../gpio
166   make -j5
167   check_make_ok
168   $sudo make install
169   check_make_ok
170
171 # echo
172 # echo "Examples"
173 # cd ../examples
174 # make
175 # cd ..
176
177 echo
178 echo All Done.
179 echo ""
180 echo "NOTE: To compile programs with wiringPi, you need to add:"
181 echo "    -lwiringPi"
182 echo "  to your compile line(s) To use the Gertboard, MaxDetect, etc."
183 echo "  code (the devLib), you need to also add:"
184 echo "    -lwiringPiDev"
185 echo "  to your compile line(s)."
186 echo ""