blob: cc6804a6a7f3e544fa5edc7affddd0bd910e3766 [file] [log] [blame]
Gordon Hendersonc4335192012-08-18 20:07:42 +01001#!/bin/bash
2
Gordon Hendersonc82fb872013-01-15 22:38:21 +00003i2c-install()
4{
5 echo "* wiringPi needs the I2C Development Libraires installing."
6 echo ""
7 echo "If using Debian/Raspbian, then type this command:"
8 echo " sudo apt-get install libi2c-dev"
9 echo "then run ./build again."
10 echo ""
11 echo "If using another Linux distribution, then you will have to"
12 echo "work out how to install the I2C Developmen Libraries for your"
13 echo "system. (Sorry - I don't know - do let me know though!)"
14 echo ""
15 exit 1
16}
17
18check-make-ok()
19{
20 if [ $? != 0 ]; then
21 echo ""
22 echo "Make Failed..."
23 echo "Please check the messages and fix any problems. If you're still stuck,"
24 echo "then please email all the output and as many details as you can to"
25 echo " projects@drogon.net"
26 echo ""
27 exit 1
28 fi
29}
30
31
Gordon Hendersonc4335192012-08-18 20:07:42 +010032if [ x$1 = "xclean" ]; then
33 echo Cleaning
34 echo
35 cd wiringPi
36 make clean
37 cd ../gpio
38 make clean
39 cd ../examples
40 make clean
41 cd ..
Gordon Henderson183c5a62012-10-21 15:25:16 +010042elif [ x$1 = "xuninstall" ]; then
43 echo Uninstalling
44 echo
45 echo "WiringPi library"
46 cd wiringPi
47 sudo make uninstall
48 echo
49 echo "GPIO Utility"
50 cd ../gpio
51 sudo make uninstall
52 cd ..
Gordon Hendersonc4335192012-08-18 20:07:42 +010053else
54 echo wiringPi Build script - please wait...
55 echo
Gordon Hendersonc82fb872013-01-15 22:38:21 +000056
57# Check for I2C being installed...
58
Gordon Henderson4673e382013-01-15 15:45:32 +000059 if [ ! -f /usr/include/linux/i2c-dev.h ]; then
Gordon Hendersonc82fb872013-01-15 22:38:21 +000060 i2c-install
61 fi
62 grep -q i2c_smbus_read_byte /usr/include/linux/i2c-dev.h
63 if [ $? = 1 ]; then
64 i2c-install
Gordon Henderson4673e382013-01-15 15:45:32 +000065 fi
66
Gordon Henderson183c5a62012-10-21 15:25:16 +010067 echo "WiringPi library"
Gordon Hendersonc4335192012-08-18 20:07:42 +010068 cd wiringPi
Gordon Hendersonc1213492013-01-15 15:30:26 +000069 sudo make uninstall
Gordon Hendersonc82fb872013-01-15 22:38:21 +000070 make
71 check-make-ok
Gordon Hendersonc4335192012-08-18 20:07:42 +010072 sudo make install
Gordon Hendersonc82fb872013-01-15 22:38:21 +000073 check-make-ok
Gordon Henderson183c5a62012-10-21 15:25:16 +010074 echo
75 echo "GPIO Utility"
Gordon Hendersonc4335192012-08-18 20:07:42 +010076 cd ../gpio
77 make
Gordon Hendersonc82fb872013-01-15 22:38:21 +000078 check-make-ok
Gordon Hendersonc4335192012-08-18 20:07:42 +010079 sudo make install
Gordon Hendersonc82fb872013-01-15 22:38:21 +000080 check-make-ok
Gordon Henderson183c5a62012-10-21 15:25:16 +010081 echo
82 echo "Examples"
Gordon Hendersonc4335192012-08-18 20:07:42 +010083 cd ../examples
84 make
85 cd ..
86fi
87
88echo
89echo All Done.