bootstrap 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/bin/sh
  2. # This file is in the public domain.
  3. # We can't set -eu because we encounter warnings which
  4. # result in stops, whereas the warnings can for now be
  5. # safely ignored.
  6. # set -eu
  7. cleanup()
  8. {
  9. echo "Removing folder 'libltdl'..."
  10. rm -rf libltdl
  11. }
  12. # This is more portable than `which' but comes with
  13. # the caveat of not(?) properly working on busybox's ash:
  14. existence()
  15. {
  16. command -v "$1" >/dev/null 2>&1
  17. }
  18. check_uncrustify()
  19. {
  20. if existence uncrustify; then
  21. echo "Installing uncrustify hook and configuration"
  22. ln -fs contrib/build-common/conf/uncrustify.cfg uncrustify.cfg 2> /dev/null
  23. ln -fs contrib/build-common/conf/uncrustify_precommit .git/hooks/pre-commit 2> /dev/null
  24. else
  25. echo "Uncrustify not detected, hook not installed."
  26. echo "Please install uncrustify if you plan on doing development"
  27. fi
  28. }
  29. # yapf can be a suffixed binary, don't change the essential logic
  30. # of this if you change it.
  31. check_yapf()
  32. {
  33. if existence yapf || \
  34. existence yapf3.0 || \
  35. existence yapf3.1 || \
  36. existence yapf3.2 || \
  37. existence yapf3.3 || \
  38. existence yapf3.4 || \
  39. existence yapf3.5 || \
  40. existence yapf3.6 || \
  41. existence yapf3.7 || \
  42. existence yapf3.8 || \
  43. existence yapf3.9 || \
  44. existence yapf4.0; then
  45. echo "Installing yapf symlink"
  46. ln -fs contrib/build-common/conf/.style.yapf .style.yapf 2> /dev/null
  47. else
  48. echo "yapf not detected, please install yapf if you plan on contributing python code"
  49. fi
  50. }
  51. check_libtool()
  52. {
  53. echo "checking for libtoolize / libtool... "
  54. if existence libtool || \
  55. existence libtoolize || \
  56. existence glibtoolize || \
  57. existence slibtool; then
  58. autoreconf -if
  59. . "bin/pogen.sh"
  60. else
  61. echo "*** No libtoolize (libtool) or libtool found, please install it ***" >&2;
  62. exit 1
  63. fi
  64. }
  65. submodules()
  66. {
  67. # Try to update the submodule. Since bootstrap
  68. # is also invoked by distributors, we must
  69. # ignore any failing of this function as we
  70. # could have no outgoing network connection
  71. # in a restricted environment.
  72. if ! git --version >/dev/null; then
  73. echo "git not installed, skipping submodule update"
  74. else
  75. git submodule update --init || true
  76. git submodule update --recursive --remote || true
  77. git submodule sync || true
  78. fi
  79. }
  80. main()
  81. {
  82. cleanup
  83. submodules
  84. check_uncrustify
  85. check_yapf
  86. check_libtool
  87. }
  88. main "$@"