Progrider

Programming discussion

Board index
Help✓ Resolved

Makefile target always runs

I have a target called build that writes the binary into bin/tool. Every make invocation recompiles even when nothing changed. build: main.c cc -Wall main.c -o bin/tool Is the target supposed to be the actual filename? Most examples I found just use all.

2 replies

Yes. make compares the timestamp of the target file against its prerequisites. "build" never exists as a file, so it's always out of date. Name the target bin/tool, or mark build .PHONY if you want it to always run.
Got it working, wrote up the details in a separate findings post. Thanks.

Discussion resolved

This discussion is resolved. Its creator can reopen it to accept more replies.