Pregunta

I am new to Makefiles and was reading some docs on PHONY targerts. Can some one please explain what is mean by "make skips the implicit rule search for phony targets". If we are declaring a PHONY target as default target, is there any restriction?

¿Fue útil?

Solución

It means that if a target is marked as .PHONY, then it must be an explicit rule, i.e. something like

a.o: a.c
  $(CC) -o $@ -c $<

and not an implicit rule, like a pattern rule or a suffix rule. As an example, consider the following makefile:

.PHONY: a.o

all: a.o b.o

%.o: %.c
    $(CC) -o $@ -c $<

Invoking make will do the following:

$ make
cc -o b.o -c b.c
$

Note that only b.c was compiled, not a.c.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top