chiark / gitweb /
Updated the build script to better try to detect lack of i2c-dev
[wiringPi.git] / build
1 #!/bin/bash
2
3 i2c-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
18 check-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
32 if [ 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 ..
42 elif [ 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 ..
53 else
54   echo wiringPi Build script - please wait...
55   echo
56
57 # Check for I2C being installed...
58
59   if [ ! -f /usr/include/linux/i2c-dev.h ]; then
60     i2c-install
61   fi
62   grep -q i2c_smbus_read_byte /usr/include/linux/i2c-dev.h
63   if [ $? = 1 ]; then
64     i2c-install
65   fi
66
67   echo "WiringPi library"
68   cd wiringPi
69   sudo make uninstall
70   make
71   check-make-ok
72   sudo make install
73   check-make-ok
74   echo
75   echo "GPIO Utility"
76   cd ../gpio
77   make
78   check-make-ok
79   sudo make install
80   check-make-ok
81   echo
82   echo "Examples"
83   cd ../examples
84   make
85   cd ..
86 fi
87
88 echo
89 echo All Done.