🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Andrew Schorr Mon, 28 Nov 1988 20:22
GNU Make 3.20 problem with recursive makes
#1416
Author: Andrew Schorr
Date: Mon, 28 Nov 1988 20:22
82 lines
2780 bytes
Roland,

   I am having a problem with recursive makes.
I am running version 3.20 of GNU Make.

Directory /x/y contains Makefile and file1.c
Contents of Makefile:

prog: file1.o ../z/file2.o ../z/file3.o
	$(CC) $(LDFLAGS) -o prog $^
 
../z/file2.o ../z/file3.o: FRC
	cd $(@D); $(MAKE) $(@F) 

FRC:

There is no file with the name FRC; this is a phony dependency that
is intended to force recompilation.

Directory /x/z contains Makefile, file2.c, file2.h, and file3.c
file2.o: file2.c file2.h

Assume that all the targets are up to date.


When I am in directory /x/y and I type make prog, I would like
make always to invoke the recursive make in directory /x/z for both
file2.o and file3.o.  Suppose I type make prog in directory /x/y.
In version 3.13, nothing happened.
In version 3.20, I get
   cd ../z/; make file2.o 
   make: `file2.o' is up to date.
Note that it only performed the recursive make for 1 of the 2 dependencies.
If I type make -n prog, I get the correct behavior:
   cd ../z/; make file2.o 
   make: `file2.o' is up to date.
   cd ../z/; make file3.o 
   make: `file3.o' is up to date.
   cc  -o prog file1.o ../z/file2.o ../z/file3.o
   make: `prog' is up to date.


Now, suppose I switch the order of file2.o and file3.o in /x/y/Makefile:
prog: file1.o ../z/file3.o ../z/file2.o
If I type make prog, I get
   cd ../z/; make file3.o 
   make: `file3.o' is up to date.
It appears that the recursive make is invoked only for the first dependency
in the list (this holds true when there are more than 2 "recursive"
dependencies).


Finally, suppose I change /x/y/Makefile to have the following contents:

prog: file1.o ../z/file2.o ../z/file3.o
	$(CC) $(LDFLAGS) -o prog $^
 
../z/file2.o: FRC
	cd $(@D); $(MAKE) $(@F) 

FRC:
 
../z/file3.o: FRC2
	cd $(@D); $(MAKE) $(@F) 

FRC2:

If I now type make prog, I get the expected behavior:
   cd ../z/; make file2.o 
   make: `file2.o' is up to date.
   cd ../z/; make file3.o 
   make: `file3.o' is up to date.


Two observations:
   1.  This Makefile works as expected with SunPro 3.5 Make.
   2.  I realize that I could get this to work using the .PHONY target;
       however, I would like to remain compatible with other versions of make.

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

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads