I have a target that is marked as phony. I also have a file with the same name as that phony target in my directory. When I interrupt the target, it removes the file. Here's the repro script: set -eu # Try to detect bmake. make="$(which bmake || which make)" rm -rf work mkdir work cd work # Create a file with the same name as the make target we are about to run. touch aaa # Mark target aaa as phony. { printf '%s\n' ".PHONY: aaa" printf '%s\n' "aaa:" printf '\t%s\n' "sleep 10" } > Makefile # Time out before the aaa target completes. # # NB: The return code of the timeout command is not 0, # so temporarily turn of set -e. set +e timeout 2s make aaa set -e # Verify that the aaa file is still there. if [ -f aaa ]; then echo OK exit 0 else echo FAIL exit 1 fi I've tested that on FreeBSD 13.1-RELEASE amd64. Interestingly, I cannot reproduce it on macOS with bmake 20230208.
bmake is behaving as documented. You can used `.PRECIOUS` to indicate that the target should not be removed, and if you have a src file and target with same name use `.NOPATH` to indicate that the target should not be searched for via `.PATH`
(In reply to Simon J. Gerraty from comment #1) Thank you for your reply! I assumed that if you have .PHONY set, then bmake does not treat the target as a file (that's what the manual says): .PHONY The target does not correspond to an actual file; it is always considered to be out of date, and will not be created with the -t option. That's why I assumed there is no need to set .PRECIOUS and .NOPATH. Am I misunderstanding something?
Hi, Yes .PHONY effectively implies .NOPATH As for needing .PRECIOUS the behavior depends on whether we are in jobs mode. JobDeleteTarget will skip for PHONY as well as PRECIOUS but CompatDeleteTarget only looks at PRECIOUS - that should be fixed. Right now you need .PRECIOUS to protect your .PHONY target in compat mode.
The newest import of bmake into 14.0-CURRENT (bmake-20230414) seems to fix the reported issue. Thank you!