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