🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #597

Make 3.57 on archives

#597
From: ian
Date: Mon, 15 Jan 1990 10:54
56 lines
1993 bytes
I have trouble getting GNU make to rebuild archives reasonably.

In Sys V make I can do

$(LIBNAME):: $(LIBNAME)(foo.o) $(LIBNAME)(bar.o)
	$(CC) -c $(CFLAGS) $(?:.o=.c)
	ar rv $(LIBNAME) $?
	rm $?

In practice to make this work I had to define a null .c.a rule, but
otherwise it is very nice because cc and ar only get executed once.
This is a considerable advantage, especially in the case of ar. Granted
there must be some ugly special case code in SysV make to handle this.

In the case of GNU make, running with -n led me to believe that the
following might work

$(LIBNAME):: $(LIBNAME)(foo.o) $(LIBNAME)(bar.o)
	$(CC) -c $(CFLAGS) $(?:$(LIBNAME)(%.o)=%.c)
	ar rv $(LIBNAME) $(?:$(LIBNAME)(%)=%)
	rm $(?:$(LIBNAME)(%)=%)

It is a bit more complicated but the syntax is more general. Alas,
although make -n indicates exactly the right thing, when exectued
with out the -n flag $? expands to null. (An echo $? line proves
this). This seems to me to be a bug.

What I currently have is (somewhat edited):

LIBNAME = /lib/libc.a

all: libc

libc: $(LIBNAME)

CMODULES = $(LIBNAME)(signal.o)

SMODULES = $(LIBNAME)(memmove.o)

$(LIBNAME):: $(CMODULES) $(SMODULES)

$(CMODULES):
	$(CC) -c $(CFLAGS) $(%:%.o=%.c)
	ar rv $(LIBNAME) $%
	rm $%

$(SMODULES):
	$(AS) $(%:%.o=%.s)
	ar rv $(LIBNAME) $%
	rm $%

This results has the disadvantage that a) all the files get compiled
regardless of whether $(LIBNAME)(signal.o) is newer than signal.c or
not and b) ar gets seperately executed for each module.

Is this a bug? If not how can I do what I want with GNU make?
Technical Details
Message-ID: <9001151532.23189@munnari.oz.au>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!sibyl.eleceng.ua.oz.au!ian

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!sibyl.eleceng.ua.oz.au!ian
From: ian@sibyl.eleceng.ua.oz.au
Newsgroups: gnu.utils.bug
Subject: Make 3.57 on archives
Message-ID: <9001151532.23189@munnari.oz.au>
Date: 15 Jan 90 10:54:37 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 56