make: Combine By Prerequisite
1
1 2.6 Another Style of Makefile
1 =============================
1
1 When the objects of a makefile are created only by implicit rules, an
1 alternative style of makefile is possible. In this style of makefile,
1 you group entries by their prerequisites instead of by their targets.
1 Here is what one looks like:
1
1 objects = main.o kbd.o command.o display.o \
1 insert.o search.o files.o utils.o
1
1 edit : $(objects)
1 cc -o edit $(objects)
1
1 $(objects) : defs.h
1 kbd.o command.o files.o : command.h
1 display.o insert.o search.o files.o : buffer.h
1
1 Here 'defs.h' is given as a prerequisite of all the object files;
1 'command.h' and 'buffer.h' are prerequisites of the specific object
1 files listed for them.
1
1 Whether this is better is a matter of taste: it is more compact, but
1 some people dislike it because they find it clearer to put all the
1 information about each target in one place.
1