[gnu.utils.bug] GNU Make 3.55 problem with combination of -f flag and included files

schorr@AI.MIT.EDU (Andrew J. Schorr) (10/07/89)

Roland,
   I have a problem that arises from the combination of included files
and the use of the -f flag.  I am running version 3.55
of GNU make on an IBM RT PC running version 2.2.1 of AIX.

Example:
Directory x contains a Makefile and a sub-directory y.  Here is the Makefile:
   include Make.include

   Make.include: tester.c
	   touch Make.include

   tester: tester.c
	   touch $@

Sub-directory y contains one file: tester.c (a trivial C program).

In directory y, I type make -f ../Makefile tester.  I see on the screen:
   make: fopen: Make.include: No such file or directory
   touch Make.include
   make: fopen: S: No such file or directory
   cc     tester.c   -o tester
I expected to see the following:
   make: fopen: Make.include: No such file or directory
   touch Make.include
   touch tester

If I type touch tester.c; touch Make.include; make -f ../Makefile tester,
then I get (as expected):
   touch tester

But, if I type touch tester.c; make -f ../Makefile tester, then I get:
   touch Make.include
   make: fopen: S: No such file or directory
   cc     tester.c   -o tester

Based on further experimentation with the -d option and a quick look at
some stack tracebacks in dbx, my understanding of the problem is as follows:
1. the included file is correctly remade;
2. make re-execs itself;
3. for some reason, it thinks that there is an included file named S;
   it cannot find this file;
4. it appears not to know the rules in the makefile (../Makefile);
   perhaps the re-execed copy is not finding the makefile.

Note: If I type touch tester.c; make -w -f ../Makefile tester, I get the
following results:
   make: Entering directory `/u/schorr/src/test/make/x/y'
   touch Make.include
   make: Leaving directory `/u/schorr/src/test/make/x/y'
   make: Entering directory `/u/schorr/src/test/make/x/y'
   make: fopen: S -w: No such file or directory
   cc     tester.c   -o tester
   make: Leaving directory `/u/schorr/src/test/make/x/y'

These results are interesting because it now goes after a file named "S -w"
instead of "S".  It should also be noted that MAKEFLAGS is set to S by default;
so it appears that a pointer that should be pointing to the name of the makefile
is instead pointing into the area where options are stored (perhaps MAKEFLAGS
or MFLAGS).

Thanks for your help,
Andrew Schorr <dead!schorr@wheaties.ai.mit.edu>