I'm unsure whether this is a bug or just undocumented, but I found a
confusing interaction in a simple Makefile:

> .PHONY: up
> up: down | down-clean
>     docker-compose up -d
> .PHONY: up-clean
> up-clean: down-clean up
> .PHONY: down
> down:
>     docker-compose down
> .PHONY: down-clean
> down-clean:

    @echo "running down-clean"

    docker-compose down -v


The interesting parts are up: down | down-clean and up-clean:
down-clean up. Docs
<https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html>
state this is how an order-only constraint should be imposed.
My goal here is to ensure order - when running up-clean, down-clean
must be run before up. But if I'm just building up, down-clean should
*not* be built.
However, with both GNU make 3.81 (system, Mac OSX) and GNU make 4.3
(latest, gmake installed from Homebrew), I see this treated like a
normal prerequisite:

$ make up
> docker-compose down
> <...>

running down-clean

docker-compose down -v

Removing volume <...>

This is not the expected behavior. Is this an expected interaction with
.PHONY?

Thanks,
Jacob Kopczynski

Reply via email to