🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.misc.discuss
Article #72116

GNU Make archive/chaining question

#72116
From: Raymond Loy
Date: Tue, 31 Mar 1992 22:05
44 lines
1574 bytes
I've only recently started using GNU make, and I'm having a problem 
with the default archiving rules.


E.g. Say the Makefile is:

libfoo.a: libfoo.a(file.o)
	ranlib libfoo.a

And there is a source file named file.c.  Then

>make
cc    -c file.c -o file.o
ar rv libfoo.a file.o
a - file.o
ar: creating libfoo.a
ranlib libfoo.a
rm  file.o                         # Everything ok so far
>make
ar rv libfoo.a file.o              # Why does it do this????
ar: cannot open file.o
>

The second time it shouldn't do anything (except maybe say "`libfoo.a' is up 
to date"), since file.c has not been modified.  It looks like the (built-in)
chained dependency is not being handled properly.

I tried adding an implicit rule that would skip the chaining (.o) -> .o -> .c,
instead going directly (.o) -> .c :

(%.o): %.c
	$(COMPILE.c) -o $% $<
	$(AR) $(ARFLAGS) $@ $%
	$(RM) $%


With this implicit rule added, the object is archived properly.

But this extra rule shouldn't be necessary, should it?
Can anyone explain this?

Thanks,
Ray
Technical Details
Message-ID: <s3tty4l@rpi.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!rpi!loyr

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1025b4,d3d2c35a795992c0,start
X-Google-Attributes: gid1025b4,public
X-Google-ArrivalTime: 1992-03-31 14:05:54 PST
Newsgroups: gnu.misc.discuss
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!rpi!loyr
From: loyr@deneb.cs.rpi.edu (Raymond Loy)
Subject: GNU Make archive/chaining question
Message-ID: <s3tty4l@rpi.edu>
Nntp-Posting-Host: deneb.cs.rpi.edu
Organization: Rensselaer Polytechnic Institute, Troy NY
Date: Tue, 31 Mar 1992 22:05:54 GMT
Lines: 45