2001-05-08 Tom Tromey <tromey@redhat.com>
+ For PR automake/29:
+ * ylwrap: Handle arguments to program. Remove old code that tried
+ to avoid absolute paths and add new code to do it in all cases.
+ Removed ancient logic that tried to deal with relative path.
+ * tests/Makefile.am (TESTS): Added yacc4.test.
+ * tests/yacc4.test: New file.
+
Fix for PR automake/149 and werror.test:
* automake.in (require_file_internal): Use am_line_warning or
am_conf_line_warning when suppressing error.
if %?YLWRAP%
$(SHELL) $(YLWRAP) $(YACC) $< y.tab.c $*%C_SUFFIX% y.tab.h $*.h -- $(AM_YFLAGS) $(YFLAGS)
else !%?YLWRAP%
- $(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*%C_SUFFIX%
+ $(YACC) $(AM_YFLAGS) $(YFLAGS) $<
+ sed -e '/^#/ s,$(srcdir)/,,' y.tab.c > $*%C_SUFFIX%
if test -f y.tab.h; then \
if cmp -s y.tab.h $*.h; then \
rm -f y.tab.h; \
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Usage:
-# ylwrap PROGRAM INPUT [OUTPUT DESIRED]... -- [ARGS]...
-# * PROGRAM is program to run.
+# ylwrap PROGRAM [ARGS] INPUT [OUTPUT DESIRED]... -- [ARGS]...
+# * PROGRAM is program to run; options can follow but must start with `-'.
# * INPUT is the input file
# * OUTPUT is file PROG generates
# * DESIRED is file we actually want
*/*) prog="`pwd`/$prog" ;;
esac
+# We also have to accept options here and append them to the program.
+# Why? Suppose YACC is set to `bison -y'. Clearly nobody uses
+# ylwrap, or this would have been discovered earlier!
+while :; do
+ case "$1" in
+ -*)
+ prog="$prog $1"
+ shift
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
# The input.
input="$1"
shift
# Absolute path; do nothing.
;;
*)
- # Relative path. Make it absolute. Why? Because otherwise any
- # debugging info in the generated file will point to the wrong
- # place. This is really gross.
+ # Relative path. Make it absolute.
input="`pwd`/$input"
;;
esac
-# We don't want to use the absolute path if the input in the current
-# directory like when making a tar ball.
-input_base=`echo $input | sed -e 's|.*/||'`
-if test -f $input_base && cmp $input_base $input >/dev/null 2>&1; then
- input=$input_base
-fi
+# The directory holding the input.
+input_dir="`echo $input | sed -e 's,/[^/]*$,,'`"
pairlist=
while test "$#" -ne 0; do
mkdir $dirname || exit 1
cd $dirname
-case "$input" in
- /* | [A-Za-z]:*)
- # Absolute path; do nothing.
- ;;
- *)
- # Make a symbolic link, hard link or hardcopy.
- ln -s ../"$input" . > /dev/null 2>&1 || ln ../"$input" . > /dev/null 2>&1 || cp ../"$input" .
- ;;
-esac
+
$prog ${1+"$@"} "$input"
status=$?
/* | [A-Za-z]:*) target="$2";;
*) target="../$2";;
esac
- mv "$from" "$target" || status=$?
+
+ # Edit out `#line' or `#' directives. We don't want the
+ # resulting debug information to point at an absolute srcdir;
+ # it is better for it to just mention the .y file with no
+ # path.
+ sed -e "/^#/ s,$input_dir,," "$from" > "$target" || status=$?
else
# A missing file is only an error for the first file. This
# is a blatant hack to let us support using "yacc -d". If -d
yacc.test \
yacc2.test \
yacc3.test \
+yacc4.test \
yaccpp.test \
yaccvpath.test
yacc.test \
yacc2.test \
yacc3.test \
+yacc4.test \
yaccpp.test \
yaccvpath.test
--- /dev/null
+#! /bin/sh
+
+# Some simple tests of ylwrap functionality.
+
+. $srcdir/defs || exit 1
+
+# Fail gracefully if no autoconf.
+$needs_autoconf
+# Likewise for some other tools.
+(gcc -v) > /dev/null 2>&1 || exit 77
+(bison -V) > /dev/null 2>&1 || exit 77
+
+cat > configure.in << 'END'
+AC_INIT
+AC_CONFIG_AUX_DIR([.])
+AM_INIT_AUTOMAKE(foo, 0.1)
+PACKAGE=foo
+VERSION=0.1
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT(Makefile)
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo bar
+foo_SOURCES = parse.y foo.c
+bar_SOURCES = bar.y foo.c
+END
+
+# First parser.
+cat > parse.y << 'END'
+%{
+int yylex () {return 0;}
+void yyerror (char *s) {}
+%}
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+# Second parser.
+cat > bar.y << 'END'
+%{
+int yylex () {return 0;}
+void yyerror (char *s) {}
+%}
+%%
+fubar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+cat > foo.c << 'END'
+int main () { return 0; }
+END
+
+# We are not checking Autoconf, so we pick $YACC for it.
+YACC="bison -y"
+export YACC
+
+set -e
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+test -f ylwrap
+
+mkdir sub
+cd sub
+
+../configure
+$MAKE
+
+grep '^#.*/sub/\.\./' bar.c && exit 1
+grep '^#.*/sub/\.\./' parse.c && exit 1
+
+exit 0
if %?YLWRAP%
$(SHELL) $(YLWRAP) $(YACC) $< y.tab.c $*%C_SUFFIX% y.tab.h $*.h -- $(AM_YFLAGS) $(YFLAGS)
else !%?YLWRAP%
- $(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*%C_SUFFIX%
+ $(YACC) $(AM_YFLAGS) $(YFLAGS) $<
+ sed -e '/^#/ s,$(srcdir)/,,' y.tab.c > $*%C_SUFFIX%
if test -f y.tab.h; then \
if cmp -s y.tab.h $*.h; then \
rm -f y.tab.h; \
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Usage:
-# ylwrap PROGRAM INPUT [OUTPUT DESIRED]... -- [ARGS]...
-# * PROGRAM is program to run.
+# ylwrap PROGRAM [ARGS] INPUT [OUTPUT DESIRED]... -- [ARGS]...
+# * PROGRAM is program to run; options can follow but must start with `-'.
# * INPUT is the input file
# * OUTPUT is file PROG generates
# * DESIRED is file we actually want
*/*) prog="`pwd`/$prog" ;;
esac
+# We also have to accept options here and append them to the program.
+# Why? Suppose YACC is set to `bison -y'. Clearly nobody uses
+# ylwrap, or this would have been discovered earlier!
+while :; do
+ case "$1" in
+ -*)
+ prog="$prog $1"
+ shift
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
# The input.
input="$1"
shift
# Absolute path; do nothing.
;;
*)
- # Relative path. Make it absolute. Why? Because otherwise any
- # debugging info in the generated file will point to the wrong
- # place. This is really gross.
+ # Relative path. Make it absolute.
input="`pwd`/$input"
;;
esac
-# We don't want to use the absolute path if the input in the current
-# directory like when making a tar ball.
-input_base=`echo $input | sed -e 's|.*/||'`
-if test -f $input_base && cmp $input_base $input >/dev/null 2>&1; then
- input=$input_base
-fi
+# The directory holding the input.
+input_dir="`echo $input | sed -e 's,/[^/]*$,,'`"
pairlist=
while test "$#" -ne 0; do
mkdir $dirname || exit 1
cd $dirname
-case "$input" in
- /* | [A-Za-z]:*)
- # Absolute path; do nothing.
- ;;
- *)
- # Make a symbolic link, hard link or hardcopy.
- ln -s ../"$input" . > /dev/null 2>&1 || ln ../"$input" . > /dev/null 2>&1 || cp ../"$input" .
- ;;
-esac
+
$prog ${1+"$@"} "$input"
status=$?
/* | [A-Za-z]:*) target="$2";;
*) target="../$2";;
esac
- mv "$from" "$target" || status=$?
+
+ # Edit out `#line' or `#' directives. We don't want the
+ # resulting debug information to point at an absolute srcdir;
+ # it is better for it to just mention the .y file with no
+ # path.
+ sed -e "/^#/ s,$input_dir,," "$from" > "$target" || status=$?
else
# A missing file is only an error for the first file. This
# is a blatant hack to let us support using "yacc -d". If -d