]> sourceware.org Git - automake.git/commitdiff
For PR automake/29:
authorTom Tromey <tromey@redhat.com>
Wed, 9 May 2001 03:10:04 +0000 (03:10 +0000)
committerTom Tromey <tromey@redhat.com>
Wed, 9 May 2001 03:10:04 +0000 (03:10 +0000)
* 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.

ChangeLog
lib/am/yacc.am
lib/ylwrap
tests/Makefile.am
tests/Makefile.in
tests/yacc4.test [new file with mode: 0755]
yacc.am
ylwrap

index 8adede909469a78725cd85a67bc5f62c9e0c5263..9ef2b852aa8892fc05eaa2b7183ccf09868b9a1e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 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.
index 0d7e10531736d849203f9dfd9f5c3a54d067c7fa..344fb9ecb9db4b86718b6b1bedb379cd578b8430 100644 (file)
@@ -21,7 +21,8 @@
 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; \
index 8aa0314d0a75fa45c908ca08d7537db257720df7..c78cdd745674fa2849b6bb50444ee4822d4cee72 100755 (executable)
@@ -18,8 +18,8 @@
 # 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
@@ -35,6 +35,21 @@ case "$prog" in
  */*) 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
@@ -43,19 +58,13 @@ case "$input" in
     # 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
@@ -74,15 +83,7 @@ trap "cd `pwd`; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15
 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=$?
 
@@ -117,7 +118,12 @@ if test $status -eq 0; then
           /* | [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
index ab886ad1c9e48311eece50177cae8a776a8e5c52..2583ee4da90cec19622a6e1f74f4a3e36cefe99b 100644 (file)
@@ -285,6 +285,7 @@ xsource.test \
 yacc.test \
 yacc2.test \
 yacc3.test \
+yacc4.test \
 yaccpp.test \
 yaccvpath.test
 
index bdb453e88d7223b7fcf82db94e1e2f795b505262..a6f1a94d743abf6973deaf095c481f9045a4ab58 100644 (file)
@@ -357,6 +357,7 @@ xsource.test \
 yacc.test \
 yacc2.test \
 yacc3.test \
+yacc4.test \
 yaccpp.test \
 yaccvpath.test
 
diff --git a/tests/yacc4.test b/tests/yacc4.test
new file mode 100755 (executable)
index 0000000..769ca5e
--- /dev/null
@@ -0,0 +1,75 @@
+#! /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
diff --git a/yacc.am b/yacc.am
index 0d7e10531736d849203f9dfd9f5c3a54d067c7fa..344fb9ecb9db4b86718b6b1bedb379cd578b8430 100644 (file)
--- a/yacc.am
+++ b/yacc.am
@@ -21,7 +21,8 @@
 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; \
diff --git a/ylwrap b/ylwrap
index 8aa0314d0a75fa45c908ca08d7537db257720df7..c78cdd745674fa2849b6bb50444ee4822d4cee72 100755 (executable)
--- a/ylwrap
+++ b/ylwrap
@@ -18,8 +18,8 @@
 # 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
@@ -35,6 +35,21 @@ case "$prog" in
  */*) 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
@@ -43,19 +58,13 @@ case "$input" in
     # 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
@@ -74,15 +83,7 @@ trap "cd `pwd`; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15
 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=$?
 
@@ -117,7 +118,12 @@ if test $status -eq 0; then
           /* | [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
This page took 0.078271 seconds and 5 git commands to generate.