17
17
# along with this program; if not, write to the Free Software
18
18
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
# As a special exception to the GNU General Public License, if you
21
# distribute this file as part of a program that contains a
22
# configuration script generated by Autoconf, you may include it under
23
# the same distribution terms that you use for the rest of that program.
21
# ylwrap PROGRAM INPUT [OUTPUT DESIRED]... -- [ARGS]...
22
# * PROGRAM is program to run.
26
# ylwrap INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]...
23
27
# * INPUT is the input file
24
28
# * OUTPUT is file PROG generates
25
29
# * DESIRED is file we actually want
30
# * PROGRAM is program to run
26
31
# * ARGS are passed to PROG
27
32
# Any number of OUTPUT,DESIRED pairs may be used.
32
# Make any relative path in $prog absolute.
35
*/*) prog="`pwd`/$prog" ;;
43
39
# Absolute path; do nothing.
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.
42
# Relative path. Make it absolute.
49
43
input="`pwd`/$input"
53
# We don't want to use the absolute path if the input in the current
54
# directory like when making a tar ball.
55
input_base=`echo $input | sed -e 's|.*/||'`
56
if test -f $input_base && cmp $input_base $input >/dev/null 2>&1; then
47
# The directory holding the input.
48
input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'`
49
# Quote $INPUT_DIR so we can use it in a regexp.
50
# FIXME: really we should care about more than `.' and `\'.
51
input_rx=`echo "$input_dir" | sed -e 's,\\\\,\\\\\\\\,g' -e 's,\\.,\\\\.,g'`
61
56
while test "$#" -ne 0; do
114
110
# If $2 is an absolute path name, then just use that,
115
111
# otherwise prepend `../'.
117
/* | [A-Za-z]:*) target="$2";;
113
[\\/]* | ?:[\\/]*) target="$2";;
118
114
*) target="../$2";;
120
mv "$from" "$target" || status=$?
117
# Edit out `#line' or `#' directives. We don't want the
118
# resulting debug information to point at an absolute srcdir;
119
# it is better for it to just mention the .y file with no
121
sed -e "/^#/ s,$input_rx,," "$from" > "$target" || status=$?
122
123
# A missing file is only an error for the first file. This
123
124
# is a blatant hack to let us support using "yacc -d". If -d