[net.wanted] WANTED: makefile trick

mike (06/04/82)

WANTED: trick for a makefile.

Does anybody have a slick way of updating simple commands using a Makefile
when there are several commands which can all be updated in similar ways?
For example, suppose we had a bunch of commands, and all of them
depended upon some OBJECTS, some LIBRARIES, and on their respective .o files.
The following Makefile almost works:

   COMMANDS = X Y Z
   OBJECTS  = a.o b.o c.o
   LIBRARIES= lib1 lib2

   $(COMMANDS) : $@.o $(OBJECTS) $(LIBRARIES)
	     cc -o $@ $@.o $(OBJECTS) $(LIBRARIES)

Problem:  the dependency  "$(COMMANDS) : $@.o" doesn't work the way we want.

A slightly different rule:

   $(COMMANDS) :  $(OBJECTS) $(LIBRARIES)
	     make $@.o
	     cc -o $@ $@.o $(OBJECTS) $(LIBRARIES)

is close, but can't figure out that a command depends on its own object.

Well?

- M. J. Hawley
rabbit!mike

stevenm (06/04/82)

This has enough general interest that I thought I would
publish it.



To: tekmdp!teklabs!decvax!harpo!npois!alice!rabbit!mike
Subject: Re: WANTED: makefile trick
In-reply-to: Your news article rabbit.506 of Thu Jun  3 19:12:59 1982
-----------------

If you are running a system which can support the version of
make(1) that was distributed to the world with System III
(that is, post USG 3.0) then, look in "An Augmented Version
of MAKE" by E.G. Bradford under the section "Synamic Dependecy
Paramters". It says:

"... $$@ refers to the current 'thing' on the left of the colon
(which is $@). ...For instance the UNIX command directory could
have the makefile:

CMDS=cat dd echo date cc cmp comm ar chown

$(CMDS): $$@.c
	$(CC) -O $? -o $@
"

I hope this answers your question. By the way, what you are asking
for is not possible, to the best of my knowledge, on pre-3.0 versions
of Make.

S. McGeady