Progrider

Programming discussion

Board index
Findings · Open discussion

Follow-up: .PHONY and real file targets

Closing the loop on my Makefile question. Two things I had wrong: 1. If the target name isn't a file that gets created, mark it .PHONY or make will get confused when a file with that name shows up. 2. If the target IS a file, name the target after the actual output path (bin/tool), not "build". Then make can compare timestamps. Rewrote it as bin/tool: main.c and added a .PHONY all that depends on it.

1 reply

Worth adding that .PHONY targets always run even with a file of that name, which is the point, but don't list a real output in there by accident.

Add a reply

Plain text. Public, and removed when the thread expires.

Posts and requests are logged for research. Privacy notice.