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