blob: b42a25a66bdcc7c90a90018c3506fa4082bb65d0 [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:
Gordon Hendersonb1dfc182016-12-12 14:19:55 +00009# A "wiring" library for the Raspberry Pi
Gordon Hendersoneb1fc2c2015-01-30 18:14:49 +000010#
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 Hendersonb0a60c32016-02-29 06:57:38 +000065 cd ../scrollPhat
66 echo -n "scrollPhat: " ; make clean
Gordon Hendersondb925ce2013-01-19 21:46:13 +000067 exit
68fi
69
70if [ x$1 = "xuninstall" ]; then
Gordon Henderson183c5a62012-10-21 15:25:16 +010071 cd wiringPi
Ian Jackson73aa8952015-09-12 16:41:38 +000072 echo -n "wiringPi: " ; $sudo make uninstall
Gordon Hendersonda384432013-05-13 19:43:26 +010073 cd ../devLib
Ian Jackson73aa8952015-09-12 16:41:38 +000074 echo -n "DevLib: " ; $sudo make uninstall
Gordon Henderson183c5a62012-10-21 15:25:16 +010075 cd ../gpio
Ian Jackson73aa8952015-09-12 16:41:38 +000076 echo -n "gpio: " ; $sudo make uninstall
Gordon Hendersondb925ce2013-01-19 21:46:13 +000077 exit
78fi
79
Gordon Henderson7cb81742015-01-31 16:43:08 +000080# Only if you know what you're doing!
81
82if [ x$1 = "xdebian" ]; then
83 here=`pwd`
Ian Jacksonac0f0742015-09-12 17:25:39 +000084 cd debian-template/wiringPi
Gordon Henderson7cb81742015-01-31 16:43:08 +000085 rm -rf usr
86 cd $here/wiringPi
87 make install-deb
88 cd $here/devLib
Ian Jacksona6ee9252015-09-10 00:09:36 +000089 make install-deb INCLUDE='-I. -I../wiringPi'
Gordon Henderson7cb81742015-01-31 16:43:08 +000090 cd $here/gpio
Ian Jacksonac0f0742015-09-12 17:25:39 +000091 make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib
92 cd $here/debian-template
Gordon Henderson7cb81742015-01-31 16:43:08 +000093 fakeroot dpkg-deb --build wiringPi
94 mv wiringPi.deb wiringpi-`cat $here/VERSION`-1.deb
95 exit
96fi
97
98if [ x$1 != "x" ]; then
99 echo "Usage: $0 [clean | uninstall]"
100 exit 1
101fi
Gordon Hendersondb925ce2013-01-19 21:46:13 +0000102
103 echo "wiringPi Build script"
104 echo "====================="
Gordon Hendersonc4335192012-08-18 20:07:42 +0100105 echo
Gordon Hendersonc82fb872013-01-15 22:38:21 +0000106
Gordon Hendersoneb1fc2c2015-01-30 18:14:49 +0000107 hardware=`fgrep Hardware /proc/cpuinfo | head -1 | awk '{ print $3 }'`
108
Gordon Henderson72b2af22015-02-03 14:53:32 +0000109# if [ x$hardware != "xBCM2708" ]; then
110# echo ""
111# echo " +------------------------------------------------------------+"
112# echo " | wiringPi is designed to run on the Raspberry Pi only. |"
113# echo " | This processor does not appear to be a Raspberry Pi. |"
114# echo " +------------------------------------------------------------+"
115# echo " | In the unlikely event that you think it is a Raspberry Pi, |"
116# echo " | then please accept my apologies and email the contents of |"
117# echo " | /proc/cpuinfo to projects@drogon.net. |"
118# echo " | - Thanks, Gordon |"
119# echo " +------------------------------------------------------------+"
120# echo ""
121# exit 1
122# fi
Gordon Hendersoneb1fc2c2015-01-30 18:14:49 +0000123
124
Gordon Hendersondb925ce2013-01-19 21:46:13 +0000125 echo
Gordon Hendersonda384432013-05-13 19:43:26 +0100126 echo "WiringPi Library"
Gordon Hendersonc4335192012-08-18 20:07:42 +0100127 cd wiringPi
Ian Jackson73aa8952015-09-12 16:41:38 +0000128 $sudo make uninstall
Gordon Henderson5e16e152013-07-28 10:54:32 +0100129 if [ x$1 = "xstatic" ]; then
Gordon Henderson7cb81742015-01-31 16:43:08 +0000130 make -j5 static
Gordon Henderson5e16e152013-07-28 10:54:32 +0100131 check_make_ok
Ian Jackson73aa8952015-09-12 16:41:38 +0000132 $sudo make install-static
Gordon Henderson5e16e152013-07-28 10:54:32 +0100133 else
Gordon Henderson7cb81742015-01-31 16:43:08 +0000134 make -j5
Gordon Henderson5e16e152013-07-28 10:54:32 +0100135 check_make_ok
Ian Jackson73aa8952015-09-12 16:41:38 +0000136 $sudo make install
Gordon Henderson5e16e152013-07-28 10:54:32 +0100137 fi
Gordon Henderson348bc732013-05-25 13:02:02 +0100138 check_make_ok
Gordon Hendersonda384432013-05-13 19:43:26 +0100139
140 echo
141 echo "WiringPi Devices Library"
142 cd ../devLib
Ian Jackson73aa8952015-09-12 16:41:38 +0000143 $sudo make uninstall
Gordon Henderson5e16e152013-07-28 10:54:32 +0100144 if [ x$1 = "xstatic" ]; then
Gordon Henderson7cb81742015-01-31 16:43:08 +0000145 make -j5 static
Gordon Henderson5e16e152013-07-28 10:54:32 +0100146 check_make_ok
Ian Jackson73aa8952015-09-12 16:41:38 +0000147 $sudo make install-static
Gordon Henderson5e16e152013-07-28 10:54:32 +0100148 else
Gordon Henderson7cb81742015-01-31 16:43:08 +0000149 make -j5
Gordon Henderson5e16e152013-07-28 10:54:32 +0100150 check_make_ok
Ian Jackson73aa8952015-09-12 16:41:38 +0000151 $sudo make install
Gordon Henderson5e16e152013-07-28 10:54:32 +0100152 fi
Gordon Henderson348bc732013-05-25 13:02:02 +0100153 check_make_ok
Gordon Hendersondb925ce2013-01-19 21:46:13 +0000154
Gordon Henderson183c5a62012-10-21 15:25:16 +0100155 echo
156 echo "GPIO Utility"
Gordon Hendersonc4335192012-08-18 20:07:42 +0100157 cd ../gpio
Gordon Henderson7cb81742015-01-31 16:43:08 +0000158 make -j5
Gordon Henderson348bc732013-05-25 13:02:02 +0100159 check_make_ok
Ian Jackson73aa8952015-09-12 16:41:38 +0000160 $sudo make install
Gordon Henderson348bc732013-05-25 13:02:02 +0100161 check_make_ok
Gordon Hendersondb925ce2013-01-19 21:46:13 +0000162
163# echo
164# echo "Examples"
165# cd ../examples
166# make
167# cd ..
Gordon Hendersonc4335192012-08-18 20:07:42 +0100168
169echo
170echo All Done.
Gordon Hendersonbfaf2662013-05-20 21:13:44 +0100171echo ""
Gordon Hendersondf453882014-07-17 22:23:57 +0100172echo "NOTE: To compile programs with wiringPi, you need to add:"
173echo " -lwiringPi"
174echo " to your compile line(s) To use the Gertboard, MaxDetect, etc."
175echo " code (the devLib), you need to also add:"
176echo " -lwiringPiDev"
177echo " to your compile line(s)."
Gordon Hendersonbfaf2662013-05-20 21:13:44 +0100178echo ""