bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Potential Bug: `.PHONY` targets and order-only prerequisites


From: Jacob Kopczynski
Subject: Potential Bug: `.PHONY` targets and order-only prerequisites
Date: Tue, 17 May 2022 14:00:59 -0700

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 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

[Prev in Thread] Current Thread [Next in Thread]