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

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 212
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 39
30 GNU make
By declaring the sub-directories as .PHONY targets (you must do this as the sub-directory
obviously always exists; otherwise it won’t be built) you can remove these problems:
SUBDIRS = foo bar baz
.PHONY: subdirs $(SUBDIRS)
subdirs: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@
foo: baz
Here we’ve also declared that the foo sub-directory cannot be built until after the baz
sub-directory is complete; this kind of relationship declaration is particularly important
when attempting parallel builds.
The implicit rule search (see Chapter 10 [Implicit Rules], page 111) is skipped for .PHONY
targets. This is why declaring a target as .PHONY is good for performance, even if you are
not worried about the actual file existing.
A phony target should not be a prerequisite of a real target file; if it is, its recipe will
be run every time make goes to update that file. As long as a phony target is never a
prerequisite of a real target, the phony target recipe will be executed only when the phony
target is a specified goal (see Section 9.2 [Arguments to Specify the Goals], page 99).
Phony targets can have prerequisites. When one directory contains multiple programs,
it is most convenient to describe all of the programs in one makefile ./Makefile. Since the
target remade by default will be the first one in the makefile, it is common to make this
a phony target named all and give it, as prerequisites, all the individual programs. For
example:
all : prog1 prog2 prog3
.PHONY : all
prog1 : prog1.o utils.o
cc -o prog1 prog1.o utils.o
prog2 : prog2.o
cc -o prog2 prog2.o
prog3 : prog3.o sort.o utils.o
cc -o prog3 prog3.o sort.o utils.o
Now you can say just ‘make to remake all three programs, or specify as arguments the ones
to remake (as in make prog1 prog3’). Phoniness is not inherited: the prerequisites of a
phony target are not themselves phony, unless explicitly declared to be so.
When one phony target is a prerequisite of another, it serves as a subroutine of the other.
For example, here make cleanall will delete the object files, the difference files, and the
file program:
.PHONY: cleanall cleanobj cleandiff
Vista de página 39
1 2 ... 35 36 37 38 39 40 41 42 43 44 45 ... 211 212

Comentários a estes Manuais

Sem comentários