summaryrefslogtreecommitdiffstats
path: root/ylwrap
diff options
context:
space:
mode:
authorKelley Cook <kcook@gcc.gnu.org>2004-09-24 11:14:51 +0000
committerR. Kelley Cook <kcook@gcc.gnu.org>2004-09-24 11:14:51 +0000
commit07a8bdf810ac5dba4ad7d287b95c907faab88a77 (patch)
tree1944dae0c76e9f7cda211717646286b80485b0e8 /ylwrap
parentObjectInputStream.java: Re-ordered imports. (diff)
downloadgcc-07a8bdf810ac5dba4ad7d287b95c907faab88a77.tar.gz
gcc-07a8bdf810ac5dba4ad7d287b95c907faab88a77.tar.bz2
gcc-07a8bdf810ac5dba4ad7d287b95c907faab88a77.tar.xz
* Revert to previous version due to Binutils breakage.
From-SVN: r88026
Diffstat (limited to 'ylwrap')
-rwxr-xr-xylwrap241
1 files changed, 71 insertions, 170 deletions
diff --git a/ylwrap b/ylwrap
index e66a95b603f..2288ccde3ac 100755
--- a/ylwrap
+++ b/ylwrap
@@ -1,11 +1,6 @@
1#! /bin/sh 1#! /bin/sh
2# ylwrap - wrapper for lex/yacc invocations. 2# ylwrap - wrapper for lex/yacc invocations.
3 3# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
4scriptversion=2004-09-10.20
5
6# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004
7# Free Software Foundation, Inc.
8#
9# Written by Tom Tromey <tromey@cygnus.com>. 4# Written by Tom Tromey <tromey@cygnus.com>.
10# 5#
11# This program is free software; you can redistribute it and/or modify 6# This program is free software; you can redistribute it and/or modify
@@ -22,81 +17,56 @@ scriptversion=2004-09-10.20
22# along with this program; if not, write to the Free Software 17# along with this program; if not, write to the Free Software
23# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 19
25# As a special exception to the GNU General Public License, if you 20# Usage:
26# distribute this file as part of a program that contains a 21# ylwrap PROGRAM INPUT [OUTPUT DESIRED]... -- [ARGS]...
27# configuration script generated by Autoconf, you may include it under 22# * PROGRAM is program to run.
28# the same distribution terms that you use for the rest of that program. 23# * INPUT is the input file
24# * OUTPUT is file PROG generates
25# * DESIRED is file we actually want
26# * ARGS are passed to PROG
27# Any number of OUTPUT,DESIRED pairs may be used.
29 28
30# This file is maintained in Automake, please report 29# The program to run.
31# bugs to <bug-automake@gnu.org> or send patches to 30prog="$1"
32# <automake-patches@gnu.org>. 31shift
33 32# Make any relative path in $prog absolute.
34case "$1" in 33case "$prog" in
35 '') 34 /* | [A-Za-z]:\\*) ;;
36 echo "$0: No files given. Try \`$0 --help' for more information." 1>&2 35 */*) prog="`pwd`/$prog" ;;
37 exit 1
38 ;;
39 --basedir)
40 basedir=$2
41 shift 2
42 ;;
43 -h|--h*)
44 cat <<\EOF
45Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]...
46
47Wrapper for lex/yacc invocations, renaming files as desired.
48
49 INPUT is the input file
50 OUTPUT is one file PROG generates
51 DESIRED is the file we actually want instead of OUTPUT
52 PROGRAM is program to run
53 ARGS are passed to PROG
54
55Any number of OUTPUT,DESIRED pairs may be used.
56
57Report bugs to <bug-automake@gnu.org>.
58EOF
59 exit 0
60 ;;
61 -v|--v*)
62 echo "ylwrap $scriptversion"
63 exit 0
64 ;;
65esac 36esac
66 37
67
68# The input. 38# The input.
69input="$1" 39input="$1"
70shift 40shift
71case "$input" in 41case "$input" in
72 [\\/]* | ?:[\\/]*) 42 /* | [A-Za-z]:\\*)
73 # Absolute path; do nothing. 43 # Absolute path; do nothing.
74 ;; 44 ;;
75 *) 45 *)
76 # Relative path. Make it absolute. 46 # Relative path. Make it absolute. Why? Because otherwise any
47 # debugging info in the generated file will point to the wrong
48 # place. This is really gross.
77 input="`pwd`/$input" 49 input="`pwd`/$input"
78 ;; 50 ;;
79esac 51esac
80 52
53# We don't want to use the absolute path if the input in the current
54# directory like when making a tar ball.
55input_base=`echo $input | sed -e 's|.*/||'`
56if test -f $input_base && cmp $input_base $input >/dev/null 2>&1; then
57 input=$input_base
58fi
59
81pairlist= 60pairlist=
82while test "$#" -ne 0; do 61while test "$#" -ne 0; do
83 if test "$1" = "--"; then 62 if test "$1" = "--"; then
84 shift 63 shift
85 break 64 break
86 fi 65 fi
87 pairlist="$pairlist $1" 66 pairlist="$pairlist $1"
88 shift 67 shift
89done 68done
90 69
91# The program to run.
92prog="$1"
93shift
94# Make any relative path in $prog absolute.
95case "$prog" in
96 [\\/]* | ?:[\\/]*) ;;
97 *[\\/]*) prog="`pwd`/$prog" ;;
98esac
99
100# FIXME: add hostname here for parallel makes that run commands on 70# FIXME: add hostname here for parallel makes that run commands on
101# other machines. But that might take us over the 14-char limit. 71# other machines. But that might take us over the 14-char limit.
102dirname=ylwrap$$ 72dirname=ylwrap$$
@@ -104,119 +74,50 @@ trap "cd `pwd`; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15
104mkdir $dirname || exit 1 74mkdir $dirname || exit 1
105 75
106cd $dirname 76cd $dirname
107 77case "$input" in
108case $# in 78 /* | [A-Za-z]:\\*)
109 0) $prog "$input" ;; 79 # Absolute path; do nothing.
110 *) $prog "$@" "$input" ;; 80 ;;
81 *)
82 # Make a symbolic link, hard link or hardcopy.
83 ln -s ../"$input" . > /dev/null 2>&1 || ln ../"$input" . > /dev/null 2>&1 || cp ../"$input" .
84 ;;
111esac 85esac
112ret=$? 86$prog ${1+"$@"} "$input"
113 87status=$?
114if test $ret -eq 0; then 88
115 set X $pairlist 89if test $status -eq 0; then
116 shift 90 set X $pairlist
117 first=yes 91 shift
118 # Since DOS filename conventions don't allow two dots, 92 first=yes
119 # the DOS version of Bison writes out y_tab.c instead of y.tab.c 93 while test "$#" -ne 0; do
120 # and y_tab.h instead of y.tab.h. Test to see if this is the case. 94 if test -f "$1"; then
121 y_tab_nodot="no" 95 # If $2 is an absolute path name, then just use that,
122 if test -f y_tab.c || test -f y_tab.h; then 96 # otherwise prepend `../'.
123 y_tab_nodot="yes" 97 case "$2" in
124 fi 98 /* | [A-Za-z]:\\*) target="$2";;
125 99 *) target="../$2";;
126 # The directory holding the input. 100 esac
127 input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'` 101 mv "$1" "$target" || status=$?
128 # Quote $INPUT_DIR so we can use it in a regexp.
129 # FIXME: really we should care about more than `.' and `\'.
130 input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'`
131
132 while test "$#" -ne 0; do
133 from="$1"
134 # Handle y_tab.c and y_tab.h output by DOS
135 if test $y_tab_nodot = "yes"; then
136 if test $from = "y.tab.c"; then
137 from="y_tab.c"
138 else 102 else
139 if test $from = "y.tab.h"; then 103 # A missing file is only an error for the first file. This
140 from="y_tab.h" 104 # is a blatant hack to let us support using "yacc -d". If -d
141 fi 105 # is not specified, we don't want an error when the header
142 fi 106 # file is "missing".
143 fi 107 if test $first = yes; then
144 if test -f "$from"; then 108 status=1
145 # If $2 is an absolute path name, then just use that, 109 fi
146 # otherwise prepend `../'.
147 case "$2" in
148 [\\/]* | ?:[\\/]*) target="$2";;
149 *) target="../$2";;
150 esac
151
152 # We do not want to overwrite a header file if it hasn't
153 # changed. This avoid useless recompilations. However the
154 # parser itself (the first file) should always be updated,
155 # because it is the destination of the .y.c rule in the
156 # Makefile. Divert the output of all other files to a temporary
157 # file so we can compare them to existing versions.
158 if test $first = no; then
159 realtarget="$target"
160 target="tmp-`echo $target | sed s/.*[\\/]//g`"
161 fi 110 fi
162 # Edit out `#line' or `#' directives. 111 shift
163 # 112 shift
164 # We don't want the resulting debug information to point at 113 first=no
165 # an absolute srcdir; it is better for it to just mention the 114 done
166 # .y file with no path.
167 #
168 # We want to use the real output file name, not yy.lex.c for
169 # instance.
170 #
171 # We want the include guards to be adjusted too.
172 FROM=`echo "$from" | sed \
173 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
174 -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
175 TARGET=`echo "$2" | sed \
176 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
177 -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
178
179 sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
180 -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
181
182 # Check whether header files must be updated.
183 if test $first = no; then
184 if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
185 echo "$2" is unchanged
186 rm -f "$target"
187 else
188 echo updating "$2"
189 mv -f "$target" "$realtarget"
190 fi
191 fi
192 else
193 # A missing file is only an error for the first file. This
194 # is a blatant hack to let us support using "yacc -d". If -d
195 # is not specified, we don't want an error when the header
196 # file is "missing".
197 if test $first = yes; then
198 ret=1
199 fi
200 fi
201 shift
202 shift
203 first=no
204 done
205else 115else
206 ret=$? 116 status=$?
207fi 117fi
208 118
209# Remove the directory. 119# Remove the directory.
210cd .. 120cd ..
211rm -rf $dirname 121rm -rf $dirname
212 122
213exit $ret 123exit $status
214
215# Local Variables:
216# mode: shell-script
217# sh-indentation: 2
218# eval: (add-hook 'write-file-hooks 'time-stamp)
219# time-stamp-start: "scriptversion="
220# time-stamp-format: "%:y-%02m-%02d.%02H"
221# time-stamp-end: "$"
222# End: