Roland Ver. 4.5 Informações Técnicas Página 18

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 212
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 17
8 GNU make
objects = main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
edit : $(objects)
cc -o edit $(objects)
main.o : defs.h
kbd.o : defs.h command.h
command.o : defs.h command.h
display.o : defs.h buffer.h
insert.o : defs.h buffer.h
search.o : defs.h buffer.h
files.o : defs.h buffer.h command.h
utils.o : defs.h
.PHONY : clean
clean :
rm edit $(objects)
This is how we would write the makefile in actual practice. (The complications associ-
ated with clean are described elsewhere. See Section 4.5 [Phony Targets], page 29, and
Section 5.5 [Errors in Recipes], page 49.)
Because implicit rules are so convenient, they are important. You will see them used
frequently.
2.6 Another Style of Makefile
When the objects of a makefile are created only by implicit rules, an alternative style of
makefile is possible. In this style of makefile, you group entries by their prerequisites instead
of by their targets. Here is what one looks like:
objects = main.o kbd.o command.o display.o \
insert.o search.o files.o utils.o
edit : $(objects)
cc -o edit $(objects)
$(objects) : defs.h
kbd.o command.o files.o : command.h
display.o insert.o search.o files.o : buffer.h
Here defs.h is given as a prerequisite of all the object files; command.h and buffer.h are
prerequisites of the specific object files listed for them.
Whether this is better is a matter of taste: it is more compact, but some people dislike
it because they find it clearer to put all the information about each target in one place.
Vista de página 17
1 2 ... 13 14 15 16 17 18 19 20 21 22 23 ... 211 212

Comentários a estes Manuais

Sem comentários