bootstrap 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/bin/sh
  2. #
  3. # We should use /usr/bin/env sh, but some systems are notoriously picky.
  4. # In fact we could omit this line if some automations wouldn't rely on
  5. # running this file via ./bootstrap.
  6. #
  7. # This file is in the public domain.
  8. # SPDX-License-Identifier: 0BSD
  9. #
  10. # We can't set -eu because we encounter warnings which
  11. # result in stops, whereas the warnings can for now be
  12. # safely ignored.
  13. # set -eu
  14. cleanup()
  15. {
  16. echo "Removing folder 'libltdl'..."
  17. rm -rf libltdl
  18. }
  19. errmsg=''
  20. # Check if shell supports builtin 'type'.
  21. if test -z "$errmsg"; then
  22. if ! (eval 'type type') >/dev/null 2>&1
  23. then
  24. errmsg='Shell does not support type builtin'
  25. exit 1
  26. fi
  27. fi
  28. # This is more portable than `which' but comes with
  29. # the caveat of not(?) properly working on busybox's ash:
  30. existence()
  31. {
  32. type "$1" >/dev/null 2>&1
  33. }
  34. check_uncrustify()
  35. {
  36. if existence uncrustify; then
  37. echo "Installing uncrustify hook and configuration"
  38. ln -fs contrib/build-common/conf/uncrustify.cfg uncrustify.cfg 2> /dev/null
  39. ln -fs contrib/build-common/conf/uncrustify_precommit .git/hooks/pre-commit 2> /dev/null
  40. else
  41. echo "Uncrustify not detected, hook not installed."
  42. echo "Please install uncrustify if you plan on doing development"
  43. fi
  44. }
  45. # yapf can be a suffixed binary, don't change the essential logic
  46. # of this if you change it.
  47. check_yapf()
  48. {
  49. if existence yapf || \
  50. existence yapf3.0 || \
  51. existence yapf3.1 || \
  52. existence yapf3.2 || \
  53. existence yapf3.3 || \
  54. existence yapf3.4 || \
  55. existence yapf3.5 || \
  56. existence yapf3.6 || \
  57. existence yapf3.7 || \
  58. existence yapf3.8 || \
  59. existence yapf3.9 || \
  60. existence yapf4.0; then
  61. echo "Installing yapf symlink"
  62. ln -fs contrib/build-common/conf/.style.yapf .style.yapf 2> /dev/null
  63. else
  64. echo "yapf not detected, please install yapf if you plan on contributing python code"
  65. fi
  66. }
  67. check_libtool()
  68. {
  69. echo "checking for libtoolize / libtool... "
  70. if existence libtool || \
  71. existence libtoolize || \
  72. existence glibtoolize || \
  73. existence slibtool; then
  74. autoreconf -if || exit 1
  75. . "bin/pogen.sh" || exit 1
  76. else
  77. echo "*** No libtoolize (libtool) or libtool found, please install it ***" >&2;
  78. exit 1
  79. fi
  80. }
  81. submodules()
  82. {
  83. # Try to update the submodule. Since bootstrap
  84. # is also invoked by distributors, we must
  85. # ignore any failing of this function as we
  86. # could have no outgoing network connection
  87. # in a restricted environment.
  88. if ! git --version >/dev/null; then
  89. echo "git not installed, skipping submodule update"
  90. else
  91. git submodule update --init || exit 1
  92. git submodule update --recursive || exit 1
  93. git submodule sync || exit 1
  94. fi
  95. }
  96. init_buildcommon_include()
  97. {
  98. cp contrib/build-common/Makefile.inc contrib/Makefile.inc || exit 1
  99. }
  100. main()
  101. {
  102. cleanup
  103. submodules
  104. init_buildcommon_include
  105. check_uncrustify
  106. check_yapf
  107. check_libtool
  108. }
  109. main "$@"