On 'make distcheck', autotools try to package the source tree with 'make
dist' first, then extract it and try to build it out-of-tree.

Unfortunately, treecc has no option which says "the source is $here, but
put the output to $there". -d looks like that, but seems to work only
for Java.

This patch works around this problem by finding out if we are doing an
out-of-tree build and copying the sources into the build dir in that
case, then running treecc and removing the .tc files afterwards. It is a
little bit hacky, but I don't see a better solution as long as treecc
doesn't support a proper -d option for all languages.

Signed-off-by: Robert Schwebel <[EMAIL PROTECTED]>

---
 
 cscc/java/Makefile.am  |   13 ++++++++++++-
 cscc/java/java_defs.tc |    2 +-
 3 files changed, 20 insertions(+), 11 deletions(-)

Index: cscc/java/Makefile.am
===================================================================
--- cscc/java/Makefile.am.orig
+++ cscc/java/Makefile.am
@@ -61,8 +61,20 @@ BUILT_SOURCES = $(STAMP) $(TREECC_OUTPUT
 
 libILJava_a_DEPENDENCIES = $(STAMP)
 
+# Hack alert: if we build out of tree, copy sources to here,
+# because treecc has no option to define the output directory
+
 $(STAMP): $(TREECC_INPUTS) $(top_builddir)/codegen/$(STAMP)
-       $(TREECC) $(srcdir)/java_defs.tc && touch $@
+       if [ "`cd $(srcdir) && pwd`" != "`pwd`" ]; then \
+               cp -f $(srcdir)/*.tc .; \
+       fi; \
+       codegen_tc=`cd $(top_srcdir)/codegen && find . -name "*.tc"`; \
+       for i in $$codegen_tc; do cp $(top_srcdir)/codegen/$$i .; done; \
+       $(TREECC) java_defs.tc && touch $@; \
+       rm -f $$codegen_tc; \
+       if [ "`cd $(srcdir) && pwd`" != "`pwd`" ]; then \
+               rm -f *.tc; \
+       fi
 
 java_scanner.l: java_grammar.c
 
Index: cscc/java/java_defs.tc
===================================================================
--- cscc/java/java_defs.tc.orig
+++ cscc/java/java_defs.tc
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-%include %readonly "../../codegen/cg_all.tc"
+%include %readonly "cg_all.tc"
 
 /*
  * Set a new header for definitions that follow.

--
 Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de
 Pengutronix - Linux Solutions for Science and Industry
   Handelsregister:  Amtsgericht Hildesheim, HRA 2686
     Hannoversche Str. 2, 31134 Hildesheim, Germany
   Phone: +49-5121-206917-0 |  Fax: +49-5121-206917-9

_______________________________________________
Developers mailing list
[email protected]
http://dotgnu.org/mailman/listinfo/developers

Reply via email to