🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #321

Some questions about GNU Make 3.54

#321
From: Andrew Thomas
Date: Wed, 26 Jul 1989 02:45
49 lines
2365 bytes
I find myself in a position where I have to keep an archive up to
date, where the files in the archive are the objecs produced by
compiling all of the C files in the directory.  The directory is very
large, so I would like to compile all of the C files which need
compiling first, and then perform the 'ar' command at the end, thereby
saving the (significant) time spent calling ar over and over again.
My incorrect solution goes something like this:

------------------------------------------------------

CC = gcc
CFLAGS = -g -fwritable-strings

TARGET = libutil.a

files := $(basename $(wildcard *.c))
objects := $(patsubst %,$(TARGET)(%),$(addsuffix .o,$(files)))

$(objects):	libutil.a(%.o):		%.c
		$(CC) $(CFLAGS) -c $?

libutil.a:	$(objects)
		$(AR) $(ARFLAGS) $@ $(patsubst $@(%),%,$?)
		ranlib $@
		$(RM) $(patsubst $@(%),%,$?)

-----------------------------------------------------

The problem here is that this makefile will recompile all of the
objects correctly, but when it does the pattern substitution on $?,
the value of $? is empty because there are in fact no members of the
archive which are more recent than the archive itself.  At this point,
I would like to see a variable which is the value of all dependencies
which were remade, as opposed to those whose dates are newer.

I eventually gave up on this, and used the implicit rules for making
archive members.  I like to pipe the output from make to a file so I
can look back at any errors, etc.  Trouble is, the 'ar' command gets
echoed out all the time, kind of cluttering up my log file.  Is there
any way to turn off the echoing in an implicit rule without turning
off echoing altogether?

One last question ... is the exact specification of the implicit rules
documented anywhere, and is it possible to replicate them exactly
using explicit directives in a makefile?  I would have been able to
solve my problem by rewriting the implicit rule for archive members,
but could not figure out how to do it.

Thanks for listening.  I fell better.
Technical Details
Message-ID: <10822@watcgl.waterloo.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!watcgl!watnext!andrewt

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!watcgl!watnext!andrewt
From: andrewt@watnext.waterloo.edu (Andrew Thomas)
Newsgroups: gnu.utils.bug
Subject: Some questions about GNU Make 3.54
Message-ID: <10822@watcgl.waterloo.edu>
Date: 26 Jul 89 02:45:49 GMT
Sender: daemon@watcgl.waterloo.edu
Lines: 49