blob: c2a589c855f8405d6f9758638c737a874120958b [file] [log] [blame]
Ian Jackson95a29282015-09-09 23:30:16 +00001#!/bin/sh -e
Gordon Hendersonc4335192012-08-18 20:07:42 +01002
Gordon Hendersoneb1fc2c2015-01-30 18:14:49 +00003# 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
Gordon Henderson348bc732013-05-25 13:02:02 +010034check_make_ok() {
Gordon Hendersonc82fb872013-01-15 22:38:21 +000035 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
Ian Jackson73aa8952015-09-12 16:41:38 +000046sudo=${WIRINGPI_SUDO-sudo}
47
Gordon Hendersonc4335192012-08-18 20:07:42 +010048if [ x$1 = "xclean" ]; then
Gordon Hendersonc4335192012-08-18 20:07:42 +010049 cd wiringPi
Gordon Hendersonbfaf2662013-05-20 21:13:44 +010050 echo -n "wiringPi: " ; make clean
Gordon Hendersonda384432013-05-13 19:43:26 +010051 cd ../devLib
Gordon Hendersonbfaf2662013-05-20 21:13:44 +010052 echo -n "DevLib: " ; make clean
Gordon Hendersonc4335192012-08-18 20:07:42 +010053 cd ../gpio
Gordon Hendersonbfaf2662013-05-20 21:13:44 +010054 echo -n "gpio: " ; make clean
Gordon Hendersonc4335192012-08-18 20:07:42 +010055 cd ../examples
Gordon Hendersonbfaf2662013-05-20 21:13:44 +010056 echo -n "Examples: " ; make clean
Gordon Hendersonda384432013-05-13 19:43:26 +010057 cd Gertboard
Gordon Hendersonbfaf2662013-05-20 21:13:44 +010058 echo -n "Gertboard: " ; make clean
Gordon Hendersonda384432013-05-13 19:43:26 +010059 cd ../PiFace
Gordon Hendersonbfaf2662013-05-20 21:13:44 +010060 echo -n "PiFace: " ; make clean
61 cd ../q2w
62 echo -n "Quick2Wire: " ; make clean
Gordon Hendersone25cbc02013-07-24 15:14:09 +010063 cd ../PiGlow
64 echo -n "PiGlow: " ; make clean
Gordon Hendersondb925ce2013-01-19 21:46:13 +000065 exit
66fi
67
68if [ x$1 = "xuninstall" ]; then
Gordon Henderson183c5a62012-10-21 15:25:16 +010069 cd wiringPi
Ian Jackson73aa8952015-09-12 16:41:38 +000070 echo -n "wiringPi: " ; $sudo make uninstall
Gordon Hendersonda384432013-05-13 19:43:26 +010071 cd ../devLib
Ian Jackson73aa8952015-09-12 16:41:38 +000072 echo -n "DevLib: " ; $sudo make uninstall
Gordon Henderson183c5a62012-10-21 15:25:16 +010073 cd ../gpio
Ian Jackson73aa8952015-09-12 16:41:38 +000074 echo -n "gpio: " ; $sudo make uninstall
Gordon Hendersondb925ce2013-01-19 21:46:13 +000075 exit
76fi
77
Gordon Henderson7cb81742015-01-31 16:43:08 +000078# Only if you know what you're doing!
79
80if [ x$1 = "xdebian" ]; then
81 here=`pwd`
Ian Jacksonac0f0742015-09-12 17:25:39 +000082 cd debian-template/wiringPi
Gordon Henderson7cb81742015-01-31 16:43:08 +000083 rm -rf usr
84 cd $here/wiringPi
85 make install-deb
86 cd $here/devLib
Ian Jacksona6ee9252015-09-10 00:09:36 +000087 make install-deb INCLUDE='-I. -I../wiringPi'
Gordon Henderson7cb81742015-01-31 16:43:08 +000088 cd $here/gpio
Ian Jacksonac0f0742015-09-12 17:25:39 +000089 make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib
90 cd $here/debian-template
Gordon Henderson7cb81742015-01-31 16:43:08 +000091 fakeroot dpkg-deb --build wiringPi
92 mv wiringPi.deb wiringpi-`cat $here/VERSION`-1.deb
93 exit
94fi
95
96if [ x$1 != "x" ]; then
97 echo "Usage: $0 [clean | uninstall]"
98 exit 1
99fi
Gordon Hendersondb925ce2013-01-19 21:46:13 +0000100
101 echo "wiringPi Build script"
102 echo "====================="
Gordon Hendersonc4335192012-08-18 20:07:42 +0100103 echo
Gordon Hendersonc82fb872013-01-15 22:38:21 +0000104
Gordon Hendersoneb1fc2c2015-01-30 18:14:49 +0000105 hardware=`fgrep Hardware /proc/cpuinfo | head -1 | awk '{ print $3 }'`
106
Gordon Henderson72b2af22015-02-03 14:53:32 +0000107# if [ x$hardware != "xBCM2708" ]; then
108# echo ""
109# echo " +------------------------------------------------------------+"
110# echo " | wiringPi is designed to run on the Raspberry Pi only. |"
111# echo " | This processor does not appear to be a Raspberry Pi. |"
112# echo " +------------------------------------------------------------+"
113# echo " | In the unlikely event that you think it is a Raspberry Pi, |"
114# echo " | then please accept my apologies and email the contents of |"
115# echo " | /proc/cpuinfo to projects@drogon.net. |"
116# echo " | - Thanks, Gordon |"
117# echo " +------------------------------------------------------------+"
118# echo ""
119# exit 1
120# fi
Gordon Hendersoneb1fc2c2015-01-30 18:14:49 +0000121
122
Gordon Hendersondb925ce2013-01-19 21:46:13 +0000123 echo
Gordon Hendersonda384432013-05-13 19:43:26 +0100124 echo "WiringPi Library"
Gordon Hendersonc4335192012-08-18 20:07:42 +0100125 cd wiringPi
Ian Jackson73aa8952015-09-12 16:41:38 +0000126 $sudo make uninstall
Gordon Henderson5e16e152013-07-28 10:54:32 +0100127 if [ x$1 = "xstatic" ]; then
Gordon Henderson7cb81742015-01-31 16:43:08 +0000128 make -j5 static
Gordon Henderson5e16e152013-07-28 10:54:32 +0100129 check_make_ok
Ian Jackson73aa8952015-09-12 16:41:38 +0000130 $sudo make install-static
Gordon Henderson5e16e152013-07-28 10:54:32 +0100131 else
Gordon Henderson7cb81742015-01-31 16:43:08 +0000132 make -j5
Gordon Henderson5e16e152013-07-28 10:54:32 +0100133 check_make_ok
Ian Jackson73aa8952015-09-12 16:41:38 +0000134 $sudo make install
Gordon Henderson5e16e152013-07-28 10:54:32 +0100135 fi
Gordon Henderson348bc732013-05-25 13:02:02 +0100136 check_make_ok
Gordon Hendersonda384432013-05-13 19:43:26 +0100137
138 echo
139 echo "WiringPi Devices Library"
140 cd ../devLib
Ian Jackson73aa8952015-09-12 16:41:38 +0000141 $sudo make uninstall
Gordon Henderson5e16e152013-07-28 10:54:32 +0100142 if [ x$1 = "xstatic" ]; then
Gordon Henderson7cb81742015-01-31 16:43:08 +0000143 make -j5 static
Gordon Henderson5e16e152013-07-28 10:54:32 +0100144 check_make_ok
Ian Jackson73aa8952015-09-12 16:41:38 +0000145 $sudo make install-static
Gordon Henderson5e16e152013-07-28 10:54:32 +0100146 else
Gordon Henderson7cb81742015-01-31 16:43:08 +0000147 make -j5
Gordon Henderson5e16e152013-07-28 10:54:32 +0100148 check_make_ok
Ian Jackson73aa8952015-09-12 16:41:38 +0000149 $sudo make install
Gordon Henderson5e16e152013-07-28 10:54:32 +0100150 fi
Gordon Henderson348bc732013-05-25 13:02:02 +0100151 check_make_ok
Gordon Hendersondb925ce2013-01-19 21:46:13 +0000152
Gordon Henderson183c5a62012-10-21 15:25:16 +0100153 echo
154 echo "GPIO Utility"
Gordon Hendersonc4335192012-08-18 20:07:42 +0100155 cd ../gpio
Gordon Henderson7cb81742015-01-31 16:43:08 +0000156 make -j5
Gordon Henderson348bc732013-05-25 13:02:02 +0100157 check_make_ok
Ian Jackson73aa8952015-09-12 16:41:38 +0000158 $sudo make install
Gordon Henderson348bc732013-05-25 13:02:02 +0100159 check_make_ok
Gordon Hendersondb925ce2013-01-19 21:46:13 +0000160
161# echo
162# echo "Examples"
163# cd ../examples
164# make
165# cd ..
Gordon Hendersonc4335192012-08-18 20:07:42 +0100166
167echo
168echo All Done.
Gordon Hendersonbfaf2662013-05-20 21:13:44 +0100169echo ""
Gordon Hendersondf453882014-07-17 22:23:57 +0100170echo "NOTE: To compile programs with wiringPi, you need to add:"
171echo " -lwiringPi"
172echo " to your compile line(s) To use the Gertboard, MaxDetect, etc."
173echo " code (the devLib), you need to also add:"
174echo " -lwiringPiDev"
175echo " to your compile line(s)."
Gordon Hendersonbfaf2662013-05-20 21:13:44 +0100176echo ""