]> git.ipfire.org Git - thirdparty/gcc.git/blame - contrib/gcc_update
Add libsanitizer generated files
[thirdparty/gcc.git] / contrib / gcc_update
CommitLineData
a2e539b0 1#! /bin/sh
2#
3ca46d61 3# Update a local Subversion, Git or Mercurial tree from the GCC
4# repository, with an emphasis on treating generated files correctly, so
5# that autoconf, gperf et al are not required for the ``end'' user.
a2e539b0 6#
9a4818f1 7# (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
8# 2011 Free Software Foundation
a1ed82f1 9# Originally by Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>, August 1998.
10#
11# This script is Free Software, and it can be copied, distributed and
12# modified as defined in the GNU General Public License. A copy of
13# its license can be downloaded from http://www.gnu.org/copyleft/gpl.html
14#
15#
3ca46d61 16# By default all command-line options are passed to `svn update` or `hg/git
17# pull` in addition to $UPDATE_OPTIONS (defined below). If the first parameter
83dbb020 18# reads --nostdflags, $UPDATE_OPTIONS as well as this parameter itself
175a12a4 19# are omitted.
20#
26a9ebc7 21# If the first parameter reads --patch, the second parameter is considered
22# a patch file.
175a12a4 23#
a1ed82f1 24# If the first parameter is --touch, no svn operation will be performed,
2a3c682c 25# only generated files that appear to be out of date in the local tree
26# will be touched.
27#
28# If the first parameter is --list, a list of the generated files and
29# their dependencies will be printed; --help prints this message.
30#
5f0f7c87 31# If the first parameter is --silent, this script prints nothing other
32# than error messages; the second parameter is then interpreted as above.
33#
83dbb020 34# Examples:
35#
a1ed82f1 36# contrib/gcc_update -r 8712
f0e2ad08 37# contrib/gcc_update --patch some-patch
38# contrib/gcc_update --touch
39# contrib/gcc_update --list
384df7ea 40
a2e539b0 41
3ca46d61 42# Default options used when updating (none).
a1ed82f1 43UPDATE_OPTIONS=""
683512c4 44
7da6fed2 45# Set the locale to C to make this script work for users with foreign
46# locale like e.g. French UTF-8.
47LANG=C
48LC_ALL=C
49export LANG LC_ALL
50
683512c4 51######## Anything below shouldn't be changed by regular users.
a2e539b0 52
41698bd2 53# Arrange for the value of $0 to be available for functions
54self=$0
a2e539b0 55
5f0f7c87 56# This function prints its arguments to standard output unless
57# "silent" is set.
6954117a 58unset silent
5f0f7c87 59chat () {
60 if [ -z "$silent" ]; then
61 echo "$@"
62 fi
63}
64
2a3c682c 65# This function prints a list of all generated files, along with their
66# dependencies. Note that only one target is supported per line: the
67# colon is stripped from the output.
68files_and_dependencies () {
69 sed -e 's/ *#.*//' -e '/^$/d' -e 's/://' <<\EOF
2b59cb05 70# fixincludes
71fixincludes/configure: fixincludes/configure.ac fixincludes/aclocal.m4
72fixincludes/config.h.in: fixincludes/configure.ac fixincludes/aclocal.m4
1e12d536 73# intl library
74intl/plural.c: intl/plural.y
35620caa 75intl/configure: intl/configure.ac intl/aclocal.m4
76intl/config.h.in: intl/configure.ac intl/aclocal.m4
2a3c682c 77# Now, proceed to gcc automatically generated files
325d776d 78gcc/configure: gcc/configure.ac
79gcc/cstamp-h.in: gcc/configure.ac
fd0e3478 80gcc/config.in: gcc/cstamp-h.in
2a3c682c 81gcc/fixinc/fixincl.x: gcc/fixinc/fixincl.tpl gcc/fixinc/inclhack.def
a4946526 82gcc/config/arm/arm-tune.md: gcc/config/arm/arm-cores.def gcc/config/arm/gentune.sh
bcbb3950 83gcc/config/arm/arm-tables.opt: gcc/config/arm/arm-arches.def gcc/config/arm/arm-cores.def gcc/config/arm/arm-fpus.def gcc/config/arm/genopt.sh
c1535dd2 84gcc/config/avr/avr-tables.opt: gcc/config/avr/avr-mcus.def gcc/config/avr/genopt.sh
b32bc361 85gcc/config/avr/t-multilib: gcc/config/avr/avr-mcus.def gcc/config/avr/genmultilib.awk
5aa04b01 86gcc/config/c6x/c6x-tables.opt: gcc/config/c6x/c6x-isas.def gcc/config/c6x/genopt.sh
87gcc/config/c6x/c6x-sched.md: gcc/config/c6x/c6x-sched.md.in gcc/config/c6x/gensched.sh
88gcc/config/c6x/c6x-mult.md: gcc/config/c6x/c6x-mult.md.in gcc/config/c6x/genmult.sh
d078aadd 89gcc/config/m68k/m68k-tables.opt: gcc/config/m68k/m68k-devices.def gcc/config/m68k/m68k-isas.def gcc/config/m68k/m68k-microarchs.def gcc/config/m68k/genopt.sh
64bd95e1 90gcc/config/mips/mips-tables.opt: gcc/config/mips/mips-cpus.def gcc/config/mips/genopt.sh
d41a5879 91gcc/config/rs6000/rs6000-tables.opt: gcc/config/rs6000/rs6000-cpus.def gcc/config/rs6000/genopt.sh
7ce78e23 92gcc/config/tilegx/mul-tables.c: gcc/config/tilepro/gen-mul-tables.cc
93gcc/config/tilepro/mul-tables.c: gcc/config/tilepro/gen-mul-tables.cc
2a3c682c 94# And then, language-specific files
ecf7b724 95gcc/cp/cfns.h: gcc/cp/cfns.gperf
96gcc/java/keyword.h: gcc/java/keyword.gperf
11d0d169 97# testsuite
98# Without this, _Pragma3.c can have a false negative.
99gcc/testsuite/gcc.dg/cpp/_Pragma3.c: gcc/testsuite/gcc.dg/cpp/mi1c.h
68f3ee71 100# Similarly, without this, you will see:
101# direct2s.c:35: warning: current file is older than direct2.c
102gcc/testsuite/gcc.dg/cpp/direct2s.c: gcc/testsuite/gcc.dg/cpp/direct2.c
7bfefa9d 103# lto-plugin
104lto-plugin/configure: lto-plugin/configure.ac lto-plugin/aclocal.m4
105lto-plugin/Makefile.in: lto-plugin/Makefile.am lto-plugin/aclocal.m4
2a3c682c 106# And libraries, at last
e7fabdb9 107libbanshee/configure: libbanshee/configure.ac
ebf99822 108libmudflap/configure: libmudflap/configure.ac
4330fb65 109libobjc/configure: libobjc/configure.ac
6d5f8e39 110zlib/aclocal.m4: zlib/configure.ac zlib/acinclude.m4
111zlib/Makefile.in: zlib/Makefile.am zlib/configure.ac zlib/aclocal.m4
112zlib/configure: zlib/configure.ac zlib/aclocal.m4
52de7f4b 113fastjar/aclocal.m4: fastjar/configure.ac
114fastjar/Makefile.in: fastjar/Makefile.am fastjar/configure.ac fastjar/aclocal.m4
115fastjar/configure: fastjar/configure.ac fastjar/aclocal.m4
cb8e0dc9 116boehm-gc/aclocal.m4: boehm-gc/configure.ac
c230ade1 117boehm-gc/Makefile.in: boehm-gc/Makefile.am boehm-gc/configure.ac boehm-gc/aclocal.m4
c1513f4f 118boehm-gc/configure: boehm-gc/configure.ac boehm-gc/aclocal.m4
04d9d4d7 119libada/configure: libada/configure.ac
9c27edfe 120libffi/aclocal.m4: libffi/configure.ac libffi/acinclude.m4
121libffi/Makefile.in: libffi/Makefile.am libffi/configure.ac libffi/aclocal.m4
122libffi/configure: libffi/configure.ac libffi/aclocal.m4
123libffi/fficonfig.h.in: libffi/configure.ac libffi/aclocal.m4
56f721bc 124libgfortran/aclocal.m4: libgfortran/configure.ac libgfortran/acinclude.m4
125libgfortran/Makefile.in: libgfortran/Makefile.am libgfortran/configure.ac libgfortran/aclocal.m4
126libgfortran/configure: libgfortran/configure.ac libgfortran/aclocal.m4
2cba138f 127libjava/aclocal.m4: libjava/configure.ac
ee3e4b65 128libjava/Makefile.in: libjava/Makefile.am libjava/configure.ac libjava/aclocal.m4
129libjava/configure: libjava/configure.ac libjava/aclocal.m4
648298e8 130libjava/libltdl/aclocal.m4: libjava/libltdl/configure.ac libjava/libltdl/acinclude.m4
131libjava/libltdl/Makefile.in: libjava/libltdl/Makefile.am libjava/libltdl/configure.ac libjava/libltdl/aclocal.m4
132libjava/libltdl/configure: libjava/libltdl/configure.ac libjava/libltdl/aclocal.m4
6153779b 133libjava/libltdl/config-h.in: libjava/libltdl/configure.ac libjava/libltdl/aclocal.m4
69a3dc95 134libcpp/aclocal.m4: libcpp/configure.ac
9f6dc1d6 135libcpp/Makefile.in: libcpp/configure.ac libcpp/aclocal.m4
69a3dc95 136libcpp/configure: libcpp/configure.ac libcpp/aclocal.m4
1e8e9920 137libgomp/aclocal.m4: libgomp/configure.ac libgomp/acinclude.m4
138libgomp/Makefile.in: libgomp/Makefile.am libgomp/aclocal.m4
1edce15c 139libgomp/testsuite/Makefile.in: libgomp/Makefile.am libgomp/aclocal.m4
1e8e9920 140libgomp/configure: libgomp/configure.ac libgomp/aclocal.m4
141libgomp/config.h.in: libgomp/configure.ac libgomp/aclocal.m4
4c0315d0 142libitm/aclocal.m4: libitm/configure.ac libitm/acinclude.m4
143libitm/Makefile.in: libitm/Makefile.am libitm/aclocal.m4
144libitm/testsuite/Makefile.in: libitm/testsuite/Makefile.am libitm/aclocal.m4
145libitm/configure: libitm/configure.ac libitm/aclocal.m4
146libitm/config.h.in: libitm/configure.ac libitm/aclocal.m4
6db1d2ca 147libatomic/aclocal.m4: libatomic/configure.ac libatomic/acinclude.m4
148libatomic/Makefile.in: libatomic/Makefile.am libatomic/aclocal.m4
149libatomic/testsuite/Makefile.in: libatomic/testsuite/Makefile.am libatomic/aclocal.m4
150libatomic/configure: libatomic/configure.ac libatomic/aclocal.m4
151libatomic/auto-config.h.in: libatomic/configure.ac libatomic/aclocal.m4
de7fbd4e 152libsanitizer/aclocal.m4: libsanitizer/configure.ac
153libsanitizer/Makefile.in: libsanitizer/Makefile.am libsanitizer/aclocal.m4
154libsanitizer/configure: libsanitizer/configure.ac libsanitizer/aclocal.m4
2a1ac811 155# Top level
156Makefile.in: Makefile.tpl Makefile.def
b632caf4 157configure: configure.ac config/acx.m4
2a3c682c 158EOF
159}
160
161
26a9ebc7 162# This function touches generated files such that the ``end'' user does
163# not have to rebuild them.
2a3c682c 164touch_files () {
083aeb9b 165 rm -f Makefile.$$
166 echo 'all: \' > Makefile.$$
167 files_and_dependencies | sed 's, .*, \\,' >> Makefile.$$
168 echo '; @true' >> Makefile.$$
169 files_and_dependencies | sed 's, ,: ,' >> Makefile.$$
170 files_and_dependencies | sed 's, .*, \\,' >> Makefile.$$
171 echo ':' >> Makefile.$$
fb5f105e 172 echo ' @for f in $? $@; do test -f $$f || exit 0; done; \' >> Makefile.$$
083aeb9b 173 echo ' echo Touching $@...; \' >> Makefile.$$
5f0f7c87 174 chat ' echo Touching $@... 1>&2; \' >> Makefile.$$
083aeb9b 175 echo ' touch $@' >> Makefile.$$
176 files_and_dependencies | sed 's,[^ ]* ,,;s,$, :,' >> Makefile.$$
dbfa75a1 177
b33f46b5 178 # We would have to explicitly shut off the "Entering... Leaving..."
dbfa75a1 179 # messages through "--no-print-directory" to handle the case when
180 # we were called from a recursive invocation (i.e. "$(MAKE)" in a
181 # Makefile, not just make). Passing only "-s" doesn't help then,
182 # because make has helpfully added "-w" to MAKEFLAGS automatically.
b33f46b5 183 # Unfortunately we do not require GNU make other than for building
184 # and testing, so let's just grep known text explicitly echoed by
185 # the rule.
186 while ${MAKE-make} -s -f Makefile.$$ all | grep Touching > /dev/null; do
083aeb9b 187 sleep 1
188 done 2>&1
189 rm -f Makefile.$$
26a9ebc7 190}
191
083aeb9b 192
3707d4b9 193# Whenever we update the tree or install a patch, we may be modifying
194# this script. By re-execing it, we ensure that the appropriate
195# dependencies and rules will be used.
196touch_files_reexec () {
5f0f7c87 197 chat "Adjusting file timestamps"
198 exec ${CONFIG_SHELL-/bin/sh} $self ${silent+"--silent"} --touch
175a12a4 199}
26a9ebc7 200
201# This functions applies a patch to an existing tree.
2a3c682c 202apply_patch () {
fadfdd5a 203 if [ -f "$1" ]; then
26a9ebc7 204 echo "Applying patch file $1"
fadfdd5a 205 case $1 in
26a9ebc7 206 *gz)
fadfdd5a 207 gzip -d -c "$1" | patch -p1 ;;
34d21c0d 208 *bz2)
fadfdd5a 209 bzip2 -d -c "$1" | patch -p1 ;;
26a9ebc7 210 *)
fadfdd5a 211 patch -p1 < "$1";;
26a9ebc7 212 esac
213 fi
3707d4b9 214 touch_files_reexec
26a9ebc7 215}
216
26a9ebc7 217# Check whether this indeed looks like a local tree.
218if [ ! -f gcc/version.c ]; then
f0e2ad08 219 echo "This does not seem to be a GCC tree!"
26a9ebc7 220 exit
a2e539b0 221fi
222
5f0f7c87 223case "$1" in
224--silent)
225 silent=t
226 shift
227 ;;
228esac
229
2a3c682c 230case "$1" in
26a9ebc7 231# First of all, check whether we are going to process a patch.
175a12a4 232--patch)
2a3c682c 233 if test "$#" != 2; then
234 echo "$1" expects only one argument >&2
235 exit 1
236 fi
237 apply_patch "${2}"
238 exit $?
239 ;;
240
241--touch)
242 if test "$#" != 1; then
243 echo "$1" does not expect any argument >&2
244 exit 1
245 fi
246 touch_files
247 exit $?
248 ;;
249
250--list)
251 if test "$#" != 1; then
252 echo "$1" does not expect any argument >&2
253 exit 1
254 fi
255 files_and_dependencies | sed 's/ /: /'
256 exit $?
257 ;;
258
259--help)
260 sed -e '1,2d' -e '/^UPDATE_OPTIONS=/{i\
261\
262
263p
264}' \
265 -e '/^$/,$d' -e 's/#//' -e 's/^ //' < $0
266 exit $?
267 ;;
268
269esac
26a9ebc7 270
3ca46d61 271# Check for known version control systems.
5e9e5d82 272if [ -d .git ]; then
273 GCC_GIT=${GCC_GIT-${GIT-git}}
3ca46d61 274 vcs_type="git"
275elif [ -d .hg ]; then
276 GCC_HG=${GCC_HG-${HG-hg}}
277 vcs_type="hg"
278elif [ -d .svn ]; then
279 GCC_SVN=${GCC_SVN-${SVN-svn}}
280 vcs_type="svn"
281else
282 echo "This does not seem to be a GCC GIT/HG/SVN tree!"
26a9ebc7 283 exit
284fi
83dbb020 285
26a9ebc7 286# Check command-line options
83dbb020 287if [ x"${1}"x = x"--nostdflags"x ]; then
288 shift
289else
290 set -- $UPDATE_OPTIONS ${1+"$@"}
291fi
292
3ca46d61 293case $vcs_type in
294 git)
295 chat "Updating GIT tree"
5f0f7c87 296
3ca46d61 297 $GCC_GIT diff --quiet --exit-code HEAD
298 if [ $? -ne 0 ]; then
299 echo "Attempting to update a dirty git tree!" >&2
300 echo "Commit or stash your changes first and retry." >&2
301 exit 1
302 fi
a2e539b0 303
3ca46d61 304 $GCC_GIT pull ${silent+-q} --rebase ${1+"$@"}
305 if [ $? -ne 0 ]; then
306 (touch_files_reexec)
307 echo "git pull of full tree failed." >&2
308 exit 1
309 fi
74d1e4d9 310
3ca46d61 311 revision=`$GCC_GIT log -n1 --pretty=%p:%t:%H`
312 branch=`$GCC_GIT name-rev --name-only HEAD || :`
313 ;;
314
315 hg)
316 chat "Updating HG tree"
317
318 # Add -q so untracked files aren't listed.
319 if [ `$GCC_HG status -q | wc -l` -gt 0 ]; then
320 echo "Attempting to update a dirty hg tree!" >&2
321 echo "Commit or revert your changes first and retry." >&2
322 exit 1
323 fi
324
325 # Check for mq extension. mq patches must be popped so tip has
326 # been converted from the SVN tree.
327 if [ -d .hg/patches ] && [ `$GCC_HG qapplied | wc -l` -gt 0 ]; then
328 # FIXME: Perhaps pop queue instead? We could do that since we
329 # know the tree is clean.
330 echo "Attempting to update hg tree with mq patches applied!" >&2
331 echo "Pop your patches first and retry." >&2
332 exit 1
333 fi
334
335 # Update tree, but make sure to only pull the default branch.
336 # Otherwise all branches in the upstream repo are added, even if
337 # only a single one has been cloned.
5a80f21c 338 $GCC_HG pull ${silent+-q} -r`$GCC_HG branch` ${1+"$@"}
3ca46d61 339 if [ $? -ne 0 ]; then
340 (touch_files_reexec)
341 echo "hg pull of full tree failed." >&2
342 exit 1
343 fi
344
5a80f21c 345 # Update tree. Needs to be done separately from pull so
346 # gcc_update -rREV works.
347 $GCC_HG update ${silent+-q} ${1+"$@"}
348 if [ $? -ne 0 ]; then
349 (touch_files_reexec)
350 echo "hg update of full tree failed." >&2
351 exit 1
352 fi
353
354 # Extract SVN revision corresponding to parents, as stored by
355 # hg convert. Before hg 1.4.3, there's no template keyword
356 # corresponding to the extra: tag, so need to use hg log --debug
357 # to extract the info.
358 parents=`$GCC_HG parents --template '{rev}'`
e438ed40 359 convert_revision=`$GCC_HG log --debug -r$parents | \
3ca46d61 360 sed -ne "/^extra:.*convert_revision=svn:/ {
e438ed40 361 s%^[^/]*/%%
3ca46d61 362 p
363 }"`
e438ed40 364 revision=`echo $convert_revision | sed -e 's/.*@//'`
365 branch=`echo $convert_revision | sed -e 's%branches/%%' -e 's/@.*//'`
3ca46d61 366 ;;
367
368 svn)
369 chat "Updating SVN tree"
370
371 $GCC_SVN ${silent+-q} --non-interactive update ${1+"$@"}
372 if [ $? -ne 0 ]; then
373 (touch_files_reexec)
374 echo "SVN update of full tree failed." >&2
375 exit 1
376 fi
377
b6134b3a 378 revision=`$GCC_SVN info | awk '/Revision:/ { print $2 }'`
379 branch=`$GCC_SVN info | sed -ne "/URL:/ {
3ca46d61 380 s,.*/trunk,trunk,
381 s,.*/branches/,,
382 s,.*/tags/,,
383 p
384 }"`
385 ;;
386esac
387
388rm -f LAST_UPDATED gcc/REVISION
8741eff3 389{
3ca46d61 390 date
391 echo "`TZ=UTC date` (revision $revision)"
8741eff3 392} > LAST_UPDATED
74d1e4d9 393echo "[$branch revision $revision]" > gcc/REVISION
394
3707d4b9 395touch_files_reexec