update-gnulib.sh 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. #! /bin/sh
  2. # Copyright (C) 2011-2022 Free Software Foundation, Inc.
  3. #
  4. # This file is part of GDB.
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. # Usage: update-gnulib.sh <path-to-gnulib-repository>
  19. # Update our import of gnulib in the GDB source tree.
  20. #
  21. # This script assumes that it is being called from the gdb/gnulib
  22. # subdirectory, and will verify this before proceeding.
  23. #
  24. # This script will also make a number of other verifications:
  25. # . The gnulib version (it should match $GNULIB_COMMIT_SHA1).
  26. # . The correct versions of the auto-tools that are used to
  27. # regenerate the various scripts and Makefiles are on the PATH.
  28. # The list of gnulib modules we are importing in GDB.
  29. IMPORTED_GNULIB_MODULES="\
  30. accept \
  31. alloca \
  32. bind \
  33. canonicalize-lgpl \
  34. chown \
  35. connect \
  36. count-one-bits \
  37. dirent \
  38. dirfd \
  39. errno \
  40. ffs \
  41. fnmatch-gnu \
  42. frexpl \
  43. gendocs \
  44. getcwd \
  45. getline \
  46. gettimeofday \
  47. gitlog-to-changelog \
  48. glob \
  49. inet_ntop
  50. inttypes \
  51. lstat \
  52. limits-h \
  53. listen \
  54. memchr \
  55. memmem \
  56. mkdir \
  57. mkdtemp \
  58. mkostemp \
  59. netdb \
  60. pathmax \
  61. rawmemchr \
  62. readlink \
  63. rename \
  64. select \
  65. setenv \
  66. setsockopt \
  67. signal-h \
  68. socket \
  69. strchrnul \
  70. strerror_r-posix \
  71. strstr \
  72. strtok_r \
  73. sys_stat \
  74. sys_wait \
  75. time_r \
  76. unistd \
  77. unsetenv \
  78. update-copyright \
  79. wchar \
  80. wctype-h \
  81. "
  82. # The gnulib commit ID to use for the update.
  83. GNULIB_COMMIT_SHA1="776af40e09b476a41073131a90022572f448c189"
  84. # The expected version number for the various auto tools we will
  85. # use after the import.
  86. AUTOCONF_VERSION="2.69"
  87. AUTOMAKE_VERSION="1.15.1"
  88. ACLOCAL_VERSION="$AUTOMAKE_VERSION"
  89. if [ $# -ne 1 ]; then
  90. echo "Error: Path to gnulib repository missing. Aborting."
  91. echo "Usage: update-gnulib.sh <path-to-gnulib-repository>"
  92. exit 1
  93. fi
  94. gnulib_prefix=$1
  95. gnulib_tool="$gnulib_prefix/gnulib-tool"
  96. # Verify that the gnulib directory does exist...
  97. if [ ! -f "$gnulib_tool" ]; then
  98. echo "Error: Invalid gnulib directory. Cannot find gnulib tool"
  99. echo " ($gnulib_tool)."
  100. echo "Aborting."
  101. exit 1
  102. fi
  103. # Verify that we have the right version of gnulib...
  104. gnulib_head_sha1=`cd $gnulib_prefix && git rev-parse HEAD`
  105. if [ "$gnulib_head_sha1" != "$GNULIB_COMMIT_SHA1" ]; then
  106. echo "Error: Wrong version of gnulib: $gnulib_head_sha1"
  107. echo " (we expected it to be $GNULIB_COMMIT_SHA1)"
  108. echo "Aborting."
  109. exit 1
  110. fi
  111. # Verify that we are in the correct directory.
  112. if [ ! -f ../gdb/main.c -o ! -d import ]; then
  113. echo "Error: This script should be called from the gnulib subdirectory."
  114. echo "Aborting."
  115. exit 1
  116. fi
  117. # Verify that we have the correct version of autoconf.
  118. ver=`autoconf --version 2>&1 | head -1 | sed 's/.*) //'`
  119. if [ "$ver" != "$AUTOCONF_VERSION" ]; then
  120. echo "Error: Wrong autoconf version ($ver), we need $AUTOCONF_VERSION."
  121. echo "Aborting."
  122. exit 1
  123. fi
  124. # Verify that we have the correct version of automake.
  125. ver=`automake --version 2>&1 | head -1 | sed 's/.*) //'`
  126. if [ "$ver" != "$AUTOMAKE_VERSION" ]; then
  127. echo "Error: Wrong automake version ($ver), we need $AUTOMAKE_VERSION."
  128. echo "Aborting."
  129. exit 1
  130. fi
  131. # Verify that we have the correct version of aclocal.
  132. #
  133. # The grep below is needed because Perl >= 5.16 dumps a "called too
  134. # early to check prototype" warning when running aclocal 1.11.1. This
  135. # causes trouble below, because the warning is the first line output
  136. # by aclocal, resulting in:
  137. #
  138. # $ sh ./update-gnulib.sh ~/src/gnulib/src/
  139. # Error: Wrong aclocal version: called too early to check prototype at /opt/automake-1.11.1/bin/aclocal line 617.. Aborting.
  140. #
  141. # Some distros carry an automake patch for that:
  142. # https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=aclocal-function-prototypes.debdiff;att=1;bug=752784
  143. #
  144. # But since we prefer pristine FSF versions of autotools, work around
  145. # the issue here. This can be removed later when we bump the required
  146. # automake version.
  147. #
  148. ver=`aclocal --version 2>&1 | grep -v "called too early to check prototype" | head -1 | sed 's/.*) //'`
  149. if [ "$ver" != "$ACLOCAL_VERSION" ]; then
  150. echo "Error: Wrong aclocal version ($ver), we need $ACLOCAL_VERSION."
  151. echo "Aborting."
  152. exit 1
  153. fi
  154. # Update our gnulib import.
  155. $gnulib_prefix/gnulib-tool --import --dir=. --lib=libgnu \
  156. --source-base=import --m4-base=import/m4 --doc-base=doc \
  157. --tests-base=tests --aux-dir=import/extra \
  158. --no-conditional-dependencies --no-libtool --macro-prefix=gl \
  159. --no-vc-files \
  160. $IMPORTED_GNULIB_MODULES
  161. if [ $? -ne 0 ]; then
  162. echo "Error: gnulib import failed. Aborting."
  163. exit 1
  164. fi
  165. # Apply our local patches.
  166. apply_patches ()
  167. {
  168. patch -p2 -f -i "$1"
  169. if [ $? -ne 0 ]; then
  170. echo "Failed to apply some patches. Aborting."
  171. exit 1
  172. fi
  173. }
  174. apply_patches "patches/0001-use-windows-stat"
  175. # Regenerate all necessary files...
  176. aclocal &&
  177. autoconf &&
  178. autoheader &&
  179. automake
  180. if [ $? -ne 0 ]; then
  181. echo "Error: Failed to regenerate Makefiles and configure scripts."
  182. exit 1
  183. fi