Subject: ylwrap appears not to support bison's lalr1.cc skeleton
From: James Bostock <[email-masked]>
To: [email-masked]
Date: Wed, 15 Dec 2010 19:27:19 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

Automake version 1.11.1
Autoconf version 2.67
Bison versions 1.875 and 2.4.1

If bison is directed to use the lalr1.cc skeleton file then although
ylwrap renames the files generated by bison, it does not update the
generated parser source code to #include the renamed header file.
Attached is a test script that illustrates the problem.

In more detail, the generated parser tries to #include the file "y.tab.h":

 48
 49 #include "y.tab.h"
 50

But y.tab.h has been renamed to zardoz.h by ylwrap, causing compilation to fail:

$ make
g++ -DPACKAGE_NAME=\"yaccpp2\" -DPACKAGE_TARNAME=\"yaccpp2\"
-DPACKAGE_VERSION=\"1.0\" -DPACKAGE_STRING=\"yaccpp2\ 1.0\"
-DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"yaccpp2\"
-DVERSION=\"1.0\" -I. -I..     -g -O2 -MT zardoz.o -MD -MP -MF
.deps/zardoz.Tpo -c -o zardoz.o zardoz.cc
zardoz.cc:49: fatal error: y.tab.h: No such file or directory
compilation terminated.

For a personal project, I made the following modifications to the
ylwrap script but I doubt that I have considered every possible usage
of ylwrap.

$ diff -u /usr/share/automake-1.11/ylwrap ylwrap
--- /usr/share/automake-1.11/ylwrap	2010-02-02 01:59:15.000000000 +0100
+++ ylwrap	2010-10-15 21:58:04.693283559 +0200
@@ -188,6 +188,17 @@
           mv -f "$target" "$realtarget"
         fi
       fi
+
+      # Update #include directives
+      case "$target" in
+	  *.cc)
+	      base=`basename $target .cc`
+	      mv $target $target.tmp
+	      sed "s/y.tab.h/$base.h/g" $target.tmp > $target
+	      rm $target.tmp
+	      ;;
+      esac
+
     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

Regards,

James