svn merge -r102224:107263 svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-3_4-branch
[official-gcc.git] / contrib / gcc_update
blobb89a9af6a431cf6ae72e9c1340fc5b8006707ab2
1 #! /bin/sh
3 # Update a local Subversion tree from the GCC repository, with an emphasis
4 # on treating generated files correctly, so that autoconf, gperf et
5 # al are not required for the ``end'' user.
7 # (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation
8 # Originally by Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>, August 1998.
10 # This script is Free Software, and it can be copied, distributed and
11 # modified as defined in the GNU General Public License. A copy of
12 # its license can be downloaded from http://www.gnu.org/copyleft/gpl.html
15 # By default all command-line options are passed to `svn update` in
16 # addition to $UPDATE_OPTIONS (defined below). If the first parameter
17 # reads --nostdflags, $UPDATE_OPTIONS as well as this parameter itself
18 # are omitted.
20 # If the first parameter reads --patch, the second parameter is considered
21 # a patch file.
23 # If the first parameter is --touch, no svn operation will be performed,
24 # only generated files that appear to be out of date in the local tree
25 # will be touched.
27 # If the first parameter is --list, a list of the generated files and
28 # their dependencies will be printed; --help prints this message.
30 # If the first parameter is --silent, this script prints nothing other
31 # than error messages; the second parameter is then interpreted as above.
33 # Examples:
35 # contrib/gcc_update -r 8712
36 # contrib/gcc_update --patch some-patch
37 # contrib/gcc_update --touch
38 # contrib/gcc_update --list
41 # SVN command
42 GCC_SVN=${GCC_SVN-${SVN-svn}}
43 # Default options used when updating via SVN (none).
44 UPDATE_OPTIONS=""
46 ######## Anything below shouldn't be changed by regular users.
48 # Arrange for the value of $0 to be available for functions
49 self=$0
51 # This function prints its arguments to standard output unless
52 # "silent" is set.
53 unset silent
54 chat () {
55 if [ -z "$silent" ]; then
56 echo "$@"
60 # This function prints a list of all generated files, along with their
61 # dependencies. Note that only one target is supported per line: the
62 # colon is stripped from the output.
63 files_and_dependencies () {
64 sed -e 's/ *#.*//' -e '/^$/d' -e 's/://' <<\EOF
65 # intl library
66 intl/plural.c: intl/plural.y
67 intl/configure: intl/configure.in intl/aclocal.m4
68 intl/config.h.in: intl/configure.in intl/aclocal.m4
69 # Now, proceed to gcc automatically generated files
70 gcc/configure: gcc/configure.ac
71 gcc/cstamp-h.in: gcc/configure.ac
72 gcc/config.in: gcc/cstamp-h.in
73 gcc/fixinc/fixincl.x: gcc/fixinc/fixincl.tpl gcc/fixinc/inclhack.def
74 # And then, language-specific files
75 gcc/f/intdoc.texi: gcc/f/intdoc.in gcc/f/intdoc.c gcc/f/intrin.h gcc/f/intrin.def
76 gcc/cp/cfns.h: gcc/cp/cfns.gperf
77 gcc/java/keyword.h: gcc/java/keyword.gperf
78 # testsuite
79 # Without this, _Pragma3.c can have a false negative.
80 gcc/testsuite/gcc.dg/cpp/_Pragma3.c: gcc/testsuite/gcc.dg/cpp/mi1c.h
81 # And libraries, at last
82 libf2c/configure: libf2c/configure.in
83 libf2c/libF77/configure: libf2c/libF77/configure.in
84 libf2c/libI77/configure: libf2c/libI77/configure.in
85 libf2c/libI77/stamp-h.in: libf2c/libI77/configure.in
86 libf2c/libI77/config.h.in: libf2c/libI77/configure.in libf2c/libI77/stamp-h.in
87 libf2c/libU77/configure: libf2c/libU77/configure.in
88 libf2c/libU77/stamp-h.in: libf2c/libU77/configure.in libf2c/libU77/acconfig.h
89 libobjc/configure: libobjc/configure.in
90 # fastjar
91 fastjar/aclocal.m4: fastjar/configure.ac
92 fastjar/Makefile.in: fastjar/Makefile.am fastjar/configure.ac fastjar/aclocal.m4
93 fastjar/configure: fastjar/configure.ac fastjar/aclocal.m4
94 boehm-gc/aclocal.m4: boehm-gc/configure.in boehm-gc/acinclude.m4
95 boehm-gc/Makefile.in: boehm-gc/Makefile.am boehm-gc/configure.in boehm-gc/aclocal.m4
96 boehm-gc/configure: boehm-gc/configure.in boehm-gc/aclocal.m4
97 libjava/aclocal.m4: libjava/configure.in libjava/acinclude.m4
98 libjava/Makefile.in: libjava/Makefile.am libjava/configure.in libjava/aclocal.m4
99 libjava/configure: libjava/configure.in libjava/aclocal.m4
100 libjava/libltdl/aclocal.m4: libjava/libltdl/configure.ac libjava/libltdl/acinclude.m4
101 libjava/libltdl/Makefile.in: libjava/libltdl/Makefile.am libjava/libltdl/configure.ac libjava/libltdl/aclocal.m4
102 libjava/libltdl/configure: libjava/libltdl/configure.ac libjava/libltdl/aclocal.m4
103 libjava/libltdl/config-h.in: libjava/libltdl/configure.ac libjava/libltdl/aclocal.m4
104 # Top level
105 Makefile.in: Makefile.tpl Makefile.def
106 configure: configure.in config/acx.m4
111 # This function touches generated files such that the ``end'' user does
112 # not have to rebuild them.
113 touch_files () {
114 rm -f Makefile.$$
115 echo 'all: \' > Makefile.$$
116 files_and_dependencies | sed 's, .*, \\,' >> Makefile.$$
117 echo '; @true' >> Makefile.$$
118 files_and_dependencies | sed 's, ,: ,' >> Makefile.$$
119 files_and_dependencies | sed 's, .*, \\,' >> Makefile.$$
120 echo ':' >> Makefile.$$
121 echo ' @for f in $? $@; do test -f $$f || exit 0; done; \' >> Makefile.$$
122 echo ' echo Touching $@...; \' >> Makefile.$$
123 chat ' echo Touching $@... 1>&2; \' >> Makefile.$$
124 echo ' touch $@' >> Makefile.$$
125 files_and_dependencies | sed 's,[^ ]* ,,;s,$, :,' >> Makefile.$$
126 while ${MAKE-make} -s -f Makefile.$$ all | grep . > /dev/null; do
127 sleep 1
128 done 2>&1
129 rm -f Makefile.$$
133 # Whenever we update the tree or install a patch, we may be modifying
134 # this script. By re-execing it, we ensure that the appropriate
135 # dependencies and rules will be used.
136 touch_files_reexec () {
137 chat "Adjusting file timestamps"
138 exec ${CONFIG_SHELL-/bin/sh} $self ${silent+"--silent"} --touch
141 # This functions applies a patch to an existing tree.
142 apply_patch () {
143 if [ -f "$1" ]; then
144 echo "Applying patch file $1"
145 case $1 in
146 *gz)
147 gzip -d -c "$1" | patch -p1 ;;
148 *bz2)
149 bzip2 -d -c "$1" | patch -p1 ;;
151 patch -p1 < "$1";;
152 esac
154 touch_files_reexec
157 # Check whether this indeed looks like a local tree.
158 if [ ! -f gcc/version.c ]; then
159 echo "This does not seem to be a GCC tree!"
160 exit
163 case "$1" in
164 --silent)
165 silent=t
166 shift
168 esac
170 case "$1" in
171 # First of all, check whether we are going to process a patch.
172 --patch)
173 if test "$#" != 2; then
174 echo "$1" expects only one argument >&2
175 exit 1
177 apply_patch "${2}"
178 exit $?
181 --touch)
182 if test "$#" != 1; then
183 echo "$1" does not expect any argument >&2
184 exit 1
186 touch_files
187 exit $?
190 --list)
191 if test "$#" != 1; then
192 echo "$1" does not expect any argument >&2
193 exit 1
195 files_and_dependencies | sed 's/ /: /'
196 exit $?
199 --help)
200 sed -e '1,2d' -e '/^UPDATE_OPTIONS=/{i\
204 }' \
205 -e '/^$/,$d' -e 's/#//' -e 's/^ //' < $0
206 exit $?
209 esac
211 # Check whether this indeed looks like a local SVN tree.
212 if [ ! -d .svn ]; then
213 echo "This does not seem to be a GCC SVN tree!"
214 exit
217 # Check command-line options
218 if [ x"${1}"x = x"--nostdflags"x ]; then
219 shift
220 else
221 set -- $UPDATE_OPTIONS ${1+"$@"}
224 chat "Updating SVN tree"
226 $GCC_SVN ${silent+-q} --non-interactive update ${1+"$@"}
227 if [ $? -ne 0 ]; then
228 (touch_files_reexec)
229 echo "SVN update of full tree failed." >&2
230 exit 1
234 date
235 echo "`TZ=UTC date` (revision `svnversion .`)"
236 } > LAST_UPDATED
237 touch_files_reexec