You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

177 line
4.8 KiB

  1. #!/bin/sh -e
  2. # build
  3. # Simple wiringPi build and install script
  4. #
  5. # Copyright (c) 2012-2015 Gordon Henderson
  6. #################################################################################
  7. # This file is part of wiringPi:
  8. # Wiring Compatable library for the Raspberry Pi
  9. #
  10. # wiringPi is free software: you can redistribute it and/or modify
  11. # it under the terms of the GNU Lesser General Public License as published by
  12. # the Free Software Foundation, either version 3 of the License, or
  13. # (at your option) any later version.
  14. #
  15. # wiringPi is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU Lesser General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU Lesser General Public License
  21. # along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
  22. #################################################################################
  23. #
  24. # wiringPi is designed to run on a Raspberry Pi only.
  25. # However if you're clever enough to actually look at this script to
  26. # see why it's not building for you, then good luck.
  27. #
  28. # To everyone else: Stop using cheap alternatives. Support the
  29. # Raspberry Pi Foundation as they're the only ones putting money
  30. # back into education!
  31. #################################################################################
  32. check_make_ok() {
  33. if [ $? != 0 ]; then
  34. echo ""
  35. echo "Make Failed..."
  36. echo "Please check the messages and fix any problems. If you're still stuck,"
  37. echo "then please email all the output and as many details as you can to"
  38. echo " projects@drogon.net"
  39. echo ""
  40. exit 1
  41. fi
  42. }
  43. sudo=${WIRINGPI_SUDO-sudo}
  44. if [ x$1 = "xclean" ]; then
  45. cd wiringPi
  46. echo -n "wiringPi: " ; make clean
  47. cd ../devLib
  48. echo -n "DevLib: " ; make clean
  49. cd ../gpio
  50. echo -n "gpio: " ; make clean
  51. cd ../examples
  52. echo -n "Examples: " ; make clean
  53. cd Gertboard
  54. echo -n "Gertboard: " ; make clean
  55. cd ../PiFace
  56. echo -n "PiFace: " ; make clean
  57. cd ../q2w
  58. echo -n "Quick2Wire: " ; make clean
  59. cd ../PiGlow
  60. echo -n "PiGlow: " ; make clean
  61. exit
  62. fi
  63. if [ x$1 = "xuninstall" ]; then
  64. cd wiringPi
  65. echo -n "wiringPi: " ; $sudo make uninstall
  66. cd ../devLib
  67. echo -n "DevLib: " ; $sudo make uninstall
  68. cd ../gpio
  69. echo -n "gpio: " ; $sudo make uninstall
  70. exit
  71. fi
  72. # Only if you know what you're doing!
  73. if [ x$1 = "xdebian" ]; then
  74. here=`pwd`
  75. cd debian-template/wiringPi
  76. rm -rf usr
  77. cd $here/wiringPi
  78. make install-deb
  79. cd $here/devLib
  80. make install-deb INCLUDE='-I. -I../wiringPi'
  81. cd $here/gpio
  82. make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib
  83. cd $here/debian-template
  84. fakeroot dpkg-deb --build wiringPi
  85. mv wiringPi.deb wiringpi-`cat $here/VERSION`-1.deb
  86. exit
  87. fi
  88. if [ x$1 != "x" ]; then
  89. echo "Usage: $0 [clean | uninstall]"
  90. exit 1
  91. fi
  92. echo "wiringPi Build script"
  93. echo "====================="
  94. echo
  95. hardware=`fgrep Hardware /proc/cpuinfo | head -1 | awk '{ print $3 }'`
  96. # if [ x$hardware != "xBCM2708" ]; then
  97. # echo ""
  98. # echo " +------------------------------------------------------------+"
  99. # echo " | wiringPi is designed to run on the Raspberry Pi only. |"
  100. # echo " | This processor does not appear to be a Raspberry Pi. |"
  101. # echo " +------------------------------------------------------------+"
  102. # echo " | In the unlikely event that you think it is a Raspberry Pi, |"
  103. # echo " | then please accept my apologies and email the contents of |"
  104. # echo " | /proc/cpuinfo to projects@drogon.net. |"
  105. # echo " | - Thanks, Gordon |"
  106. # echo " +------------------------------------------------------------+"
  107. # echo ""
  108. # exit 1
  109. # fi
  110. echo
  111. echo "WiringPi Library"
  112. cd wiringPi
  113. $sudo make uninstall
  114. if [ x$1 = "xstatic" ]; then
  115. make -j5 static
  116. check_make_ok
  117. $sudo make install-static
  118. else
  119. make -j5
  120. check_make_ok
  121. $sudo make install
  122. fi
  123. check_make_ok
  124. echo
  125. echo "WiringPi Devices Library"
  126. cd ../devLib
  127. $sudo make uninstall
  128. if [ x$1 = "xstatic" ]; then
  129. make -j5 static
  130. check_make_ok
  131. $sudo make install-static
  132. else
  133. make -j5
  134. check_make_ok
  135. $sudo make install
  136. fi
  137. check_make_ok
  138. echo
  139. echo "GPIO Utility"
  140. cd ../gpio
  141. make -j5
  142. check_make_ok
  143. $sudo make install
  144. check_make_ok
  145. # echo
  146. # echo "Examples"
  147. # cd ../examples
  148. # make
  149. # cd ..
  150. echo
  151. echo All Done.
  152. echo ""
  153. echo "NOTE: To compile programs with wiringPi, you need to add:"
  154. echo " -lwiringPi"
  155. echo " to your compile line(s) To use the Gertboard, MaxDetect, etc."
  156. echo " code (the devLib), you need to also add:"
  157. echo " -lwiringPiDev"
  158. echo " to your compile line(s)."
  159. echo ""