Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 

181 рядки
4.6 KiB

  1. #!/bin/sh -e
  2. # build
  3. # Simple wiringPi build and install script
  4. #
  5. # Copyright (c) 2012-2024 Gordon Henderson and contributors
  6. #################################################################################
  7. # This file is part of wiringPi:
  8. # A "wiring" 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 raise a GitHub issue with the output and as many details as you can"
  38. echo " https://github.com/WiringPi/WiringPi/issues"
  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. cd ../scrollPhat
  62. echo -n "scrollPhat: " ; make clean
  63. cd ../..
  64. echo -n "Deb: " ; rm -f debian-template/wiringpi*.deb
  65. echo
  66. exit
  67. fi
  68. if [ x$1 = "xuninstall" ]; then
  69. cd wiringPi
  70. echo -n "wiringPi: " ; $sudo make uninstall
  71. cd ../devLib
  72. echo -n "DevLib: " ; $sudo make uninstall
  73. cd ../gpio
  74. echo -n "gpio: " ; $sudo make uninstall
  75. exit
  76. fi
  77. # Only if you know what you're doing!
  78. if [ x$1 = "xdebian" ]; then
  79. vMaj=`cut -d. -f1 VERSION`
  80. vMin=`cut -d. -f2 VERSION`
  81. here=`pwd`
  82. deb_destdir=${here}/debian-template/wiringPi
  83. cd debian-template/wiringPi
  84. export VERSION=$vMaj.$vMin
  85. export ARCH=$(dpkg-architecture -qDEB_HOST_ARCH)
  86. echo version:$VERSION architecture:$ARCH
  87. envsubst < control_template > DEBIAN/control
  88. rm -rf usr
  89. cd $here/wiringPi
  90. make install-deb DEB_DESTDIR=${deb_destdir}
  91. cd $here/devLib
  92. make install-deb INCLUDE='-I. -I../wiringPi' DEB_DESTDIR=${deb_destdir}
  93. cd $here/gpio
  94. make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib DEB_DESTDIR=${deb_destdir}
  95. cd $here/debian-template
  96. fakeroot dpkg-deb --build wiringPi
  97. dpkg-name -o wiringPi.deb
  98. exit
  99. fi
  100. if [ x$1 != "x" ]; then
  101. echo "Usage: $0 [clean | uninstall]"
  102. exit 1
  103. fi
  104. echo "wiringPi Build script"
  105. echo "====================="
  106. echo
  107. hardware=`fgrep Hardware /proc/cpuinfo | head -1 | awk '{ print $3 }'`
  108. echo
  109. echo "WiringPi Library"
  110. cd wiringPi
  111. $sudo make uninstall
  112. if [ x$1 = "xstatic" ]; then
  113. make -j5 static
  114. check_make_ok
  115. $sudo make install-static
  116. else
  117. make -j5
  118. check_make_ok
  119. $sudo make install
  120. fi
  121. check_make_ok
  122. echo
  123. echo "WiringPi Devices Library"
  124. cd ../devLib
  125. $sudo make uninstall
  126. if [ x$1 = "xstatic" ]; then
  127. make -j5 static
  128. check_make_ok
  129. $sudo make install-static
  130. else
  131. make -j5
  132. check_make_ok
  133. $sudo make install
  134. fi
  135. check_make_ok
  136. echo
  137. echo "GPIO Utility"
  138. cd ../gpio
  139. make -j5
  140. check_make_ok
  141. $sudo make install
  142. check_make_ok
  143. # echo
  144. # echo "wiringPi Daemon"
  145. # cd ../wiringPiD
  146. # make -j5
  147. # check_make_ok
  148. # $sudo make install
  149. # check_make_ok
  150. # echo
  151. # echo "Examples"
  152. # cd ../examples
  153. # make
  154. # cd ..
  155. echo
  156. echo All Done.
  157. echo ""
  158. echo "NOTE: To compile programs with wiringPi, you need to add:"
  159. echo " -lwiringPi"
  160. echo " to your compile line(s) To use the Gertboard, MaxDetect, etc."
  161. echo " code (the devLib), you need to also add:"
  162. echo " -lwiringPiDev"
  163. echo " to your compile line(s)."
  164. echo ""