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.

74 lines
1.6 KiB

  1. #!/bin/sh
  2. # Instructions!
  3. # cd ~
  4. # wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/libgpiod.sh
  5. # chmod +x libgpiod.sh
  6. # ./libgpiod.sh
  7. is_legacy=0
  8. # Loop through arguments and process them
  9. for arg in "$@"
  10. do
  11. case $arg in
  12. -l|--legacy)
  13. is_legacy=1
  14. shift
  15. ;;
  16. *)
  17. shift
  18. ;;
  19. esac
  20. done
  21. echo "Installing build requirements - this may take a few minutes!"
  22. echo
  23. # install generic linux packages required
  24. sudo apt-get update && sudo apt-get install -y \
  25. autoconf \
  26. autoconf-archive \
  27. automake \
  28. build-essential \
  29. git \
  30. libtool \
  31. pkg-config \
  32. python3 \
  33. python3-dev \
  34. python3-setuptools \
  35. swig3.0 \
  36. wget
  37. # for raspberry pi we need...
  38. sudo apt-get install -y raspberrypi-kernel-headers
  39. build_dir=`mktemp -d /tmp/libgpiod.XXXX`
  40. echo "Cloning libgpiod repository to $build_dir"
  41. echo
  42. cd "$build_dir"
  43. git clone git://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git .
  44. if test $is_legacy = 1; then
  45. git checkout v1.4.2 -b v1.4.2
  46. fi
  47. echo "Building libgpiod"
  48. echo
  49. include_path=`python3 -c "from sysconfig import get_paths; print(get_paths()['include'])"`
  50. export PYTHON_VERSION=3
  51. ./autogen.sh --enable-tools=yes --prefix=/usr/local/ --enable-bindings-python CFLAGS="-I/$include_path" \
  52. && make \
  53. && sudo make install \
  54. && sudo ldconfig
  55. # This is not the right way to do this:
  56. sudo cp bindings/python/.libs/gpiod.so /usr/local/lib/python3.?/dist-packages/
  57. sudo cp bindings/python/.libs/gpiod.la /usr/local/lib/python3.?/dist-packages/
  58. sudo cp bindings/python/.libs/gpiod.a /usr/local/lib/python3.?/dist-packages/
  59. exit 0