chiark / gitweb /
Updates to the build process
[wiringPi.git] / build
1 #!/bin/sh
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
77   echo "wiringPi Build script"
78   echo "====================="
79   echo
80
81   hardware=`fgrep Hardware /proc/cpuinfo | head -1 | awk '{ print $3 }'`
82
83   if [ x$hardware != "xBCM2708" ]; then
84     echo ""
85     echo "   +------------------------------------------------------------+"
86     echo "   |   wiringPi is designed to run on the Raspberry Pi only.    |"
87     echo "   |   This processor does not appear to be a Raspberry Pi.     |"
88     echo "   +------------------------------------------------------------+"
89     echo "   | In the unlikely event that you think it is a Raspberry Pi, |"
90     echo "   | then please accept my apologies and email the contents of  |"
91     echo "   | /proc/cpuinfo to projects@drogon.net.                      |"
92     echo "   |    - Thanks, Gordon                                        |"
93     echo "   +------------------------------------------------------------+"
94     echo ""
95     exit 1
96   fi
97
98
99   echo
100   echo "WiringPi Library"
101   cd wiringPi
102   sudo make uninstall
103   if [ x$1 = "xstatic" ]; then
104     make static
105     check_make_ok
106     sudo make install-static
107   else
108     make
109     check_make_ok
110     sudo make install
111   fi
112   check_make_ok
113
114   echo
115   echo "WiringPi Devices Library"
116   cd ../devLib
117   sudo make uninstall
118   if [ x$1 = "xstatic" ]; then
119     make static
120     check_make_ok
121     sudo make install-static
122   else
123     make
124     check_make_ok
125     sudo make install
126   fi
127   check_make_ok
128
129   echo
130   echo "GPIO Utility"
131   cd ../gpio
132   make
133   check_make_ok
134   sudo make install
135   check_make_ok
136
137 # echo
138 # echo "Examples"
139 # cd ../examples
140 # make
141 # cd ..
142
143 echo
144 echo All Done.
145 echo ""
146 echo "NOTE: To compile programs with wiringPi, you need to add:"
147 echo "    -lwiringPi"
148 echo "  to your compile line(s) To use the Gertboard, MaxDetect, etc."
149 echo "  code (the devLib), you need to also add:"
150 echo "    -lwiringPiDev"
151 echo "  to your compile line(s)."
152 echo ""