Subject: bug#7833: automake uses two different values for DejaGNU srcdir

From: Ralf Wildenhues <[email-masked]>
Date: Fri, 14 Jan 2011 23:05:58 +0100

* Ian Lance Taylor wrote on Thu, Jan 13, 2011 at 06:29:39PM CET:
> Ralf Wildenhues writes:
> 
> > Am I correct in assuming that it is hopeless to assume GCC will work
> > when either values are relative?
> 
> Actually, as far as I know, GCC is likely to work with a relative
> srcdir.  The problem arises with DejaGNU .exp files which themselves
> change directories.  As far as I know, the GCC DejaGNU files do not do
> that.

Thanks for the feedback.

Through testing I found out again that DejaGNU does not cope with white
space in absolute directory names anyway, regardless of srcdir being
relative or absolute.  That obviates my first point.  Remains only the
fairly minor src+build-tree relocatability point.

I have these two alternative patches which I would both be happy with.
I should note that the "Life is easiest" comment dates back to the very
first addition of dejagnu support in Automake, from way before recorded
history where we could learn from a related bug.

Tried both in a multilib target directory in the GCC tree, both seem to
work.  Any preferences, from a DejaGNU standpoint?

Thanks,
Ralf

   * lib/am/dejagnu.am (check-DEJAGNU): Set srcdir to be relative,
   consistent with the --srcdir argument and the srcdir setting in
   site.exp.
   Report by Ian Lance Taylor in automake bug#7833.

--- am/dejagnu.am.orig	2011-01-14 20:27:32.000000000 +0100
+++ am/dejagnu.am.1	2011-01-14 20:27:38.000000000 +0100
@@ -1,5 +1,5 @@
 ## automake - create Makefile.in from Makefile.am
-## Copyright (C) 1994, 1995, 1996, 1997, 2000, 2001, 2003, 2006
+## Copyright (C) 1994, 1995, 1996, 1997, 2000, 2001, 2003, 2006, 2011
 ## Free Software Foundation, Inc.
 
 ## This program is free software; you can redistribute it and/or modify
@@ -43,8 +43,7 @@
 
 .PHONY: check-DEJAGNU
 check-DEJAGNU: site.exp
-## Life is easiest with an absolute srcdir, so do that.
-	srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \
+	srcdir='$(srcdir)'; export srcdir; \
 	EXPECT=$(EXPECT); export EXPECT; \
 ## Allow this to work when expect and DejaGnu are in tree.
 ## Only required when --cygnus in force.

   * lib/am/dejagnu.am (RUNTESTDEFAULTFLAGS): Quote argument
   to --srcdir.
   (site.exp): Set srcdir to "$(abs_srcdir)".
   Report by Ian Lance Taylor in automake bug#7833.

--- am/dejagnu.am.orig	2011-01-14 20:27:32.000000000 +0100
+++ am/dejagnu.am.2	2011-01-14 20:20:22.000000000 +0100
@@ -1,5 +1,5 @@
 ## automake - create Makefile.in from Makefile.am
-## Copyright (C) 1994, 1995, 1996, 1997, 2000, 2001, 2003, 2006
+## Copyright (C) 1994, 1995, 1996, 1997, 2000, 2001, 2003, 2006, 2011
 ## Free Software Foundation, Inc.
 
 ## This program is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
 DEJATOOL = $(PACKAGE)
 
 ## Default flags to pass to dejagnu.  The user can override this.
-RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
+RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir "$$srcdir"
 
 ## In Cygnus mode, these are found in the build tree.
 ## Otherwise they are looked for in $PATH.
@@ -77,7 +77,7 @@
 	@echo '## these variables are automatically generated by make ##' >site.tmp
 	@echo '# Do not edit here.  If you wish to override these values' >>site.tmp
 	@echo '# edit the last section' >>site.tmp
-	@echo 'set srcdir $(srcdir)' >>site.tmp
+	@echo 'set srcdir "$(abs_srcdir)"' >>site.tmp
 	@echo "set objdir `pwd`" >>site.tmp
 ## Quote the *_alias variables because they might be empty.
 ?BUILD?	@echo 'set build_alias "$(build_alias)"' >>site.tmp