From: utzoo!decvax!harpo!npois!alice!rabbit!mike
Newsgroups: net.wanted
Title: WANTED: makefile trick
Article-I.D.: rabbit.506
Posted: Thu Jun  3 19:12:59 1982
Received: Sat Jun  5 00:45:12 1982

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