DJGPP stage 2 C++ makefile failure

Eli Zaretskii eliz@delorie.com
Sun Jul 16 01:23:00 GMT 2000


> From: "Mark E." <snowball3@bigfoot.com>
> Date: Sat, 15 Jul 2000 16:07:25 -0400
> 
> > Add "SHELL = /bin/sh" to the Makefile and then try @echo "\$(CC)"
> > (with the quotes) instead.  Did it work now?
> 
> Adding SHELL or adding double quotes to my simplified Makefile made
> no difference.

Sorry, adding quotes was a bogus advice: it causes $ to be quoted
twice (both by a backslash and by quotes), and so is not equivalent to
the original example.

However, your original example, with only "SHELL = /bin/sh" added,
works for me.  That is, the following Makefile:

SHELL = /bin/sh

CC=/djgpp/cvs/gcc/build/gcc/stage1

all:
	@echo \$(CC)

Prints "/djgpp/cvs/gcc/build/gcc/stage1" (without the quotes), as I'd
expect.  This is with all versions of Make from 3.77 up to the latest
3.79.1.  Did you try adding SHELL= alone, without quoting CC?

> I've modifed the simplified Makefile as requested with some changes
> of my own:
> 
> SHELL=/bin/sh
> CC=/foo/gcc
> CC_DBL_QUOTED="\$(CC)"
> CC_SNGL_QUOTED='\$(CC)'
> all:
> 	echo "CC #1 = '\$(CC)'"
> 	echo "CC #2 = "\$(CC)""
> 	echo 'CC_DBL_QUOTED #1 = $(CC_DBL_QUOTED)'
> 	echo "CC_DBL_QUOTED #2 = $(CC_DBL_QUOTED)"
> 	echo 'CC_SNGL_QUOTED #1 = $(CC_SNGL_QUOTED)'
> 	echo "CC_SNGL_QUOTED #2 = $(CC_SNGL_QUOTED)"
> 
> and the output:
> 
> echo "CC #1 = '\/foo/gcc'"
> CC #1 = '\/foo/gcc'
> echo "CC #2 = "\/foo/gcc""
> CC #2 = /foo/gcc
> echo 'CC_DBL_QUOTED #1 = "\/foo/gcc"'
> CC_DBL_QUOTED #1 = "\/foo/gcc"
> echo "CC_DBL_QUOTED #2 = "\/foo/gcc""
> CC_DBL_QUOTED #2 = /foo/gcc
> echo 'CC_SNGL_QUOTED #1 = '\/foo/gcc''
> CC_SNGL_QUOTED #1 = /foo/gcc
> echo "CC_SNGL_QUOTED #2 = '\/foo/gcc'"
> CC_SNGL_QUOTED #2 = '\/foo/gcc'

This is all expected behavior: a backslash inside quotes is not
removed.  Note that the only commands where you got the backslash
stripped are those where the backslash is outside the quotes.  For
example, in this command:

  echo "CC #2 = "\/foo/gcc""

the backslash is not inside quotes, because the two quoted strings are
"CC #2 = " and "".

> Eli, is the Makefile correct in assuming
> the escape should be removed or does it need to be changed?

Since the example Makefile ``works for me'', I cannot conclude
anything specific about the real problem; I don't see any bug or
misfeature in the ported Make when I run the example.  So here are a
few more general remarks.

The backslash will be removed iff the command (a) is run by Bash, and
(b) the backslash is not inside quotes of any kind.  If the command is
run directly by Make (i.e., if Make decides that the command does not
use any features that require a shell), or if Make thinks that stock
DOS/Windows shells will be used to run the command, the backslash
stays.

It seems to me that the original problem happens because Make doesn't
invoke Bash to run the command.  The key to the problem is the command
in cp/Makefile that Make is trying to run when it prints this:

  make.exe[2]: Entering directory `c:/djgpp/cvs/gcc/build/gcc/cp'
  \gcc -c  -DIN_GCC    -g  -W -Wall    -I. -I.. -I/djgpp/cvs/gcc/gcc/cp \
       -I/djgpp/cvs/gcc/gcc/cp/.. -I/djgpp/cvs/gcc/gcc/cp/../config \
       -I/djgpp/cvs/gcc/gcc/cp/../../include /djgpp/cvs/gcc/gcc/cp/call.c
  make.exe[2]: *** [call.o] Error -1

You need to make sure this command runs via Bash; I suspect it doesn't
right now.  One way to force it to run via Bash is to prepend
"$(SHELL) -c" to it (and quote the command itself as a single string).
It's possible there are other, cleaner ways, but I cannot tell without
knowing how that command looks like in the Makefile.  Also, please
make sure that cp/Makefile does say "SHELL = /bin/sh".


More information about the Gcc-bugs mailing list