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.
Your discussion
This browser holds the management token for this post.
Save management token
Keep this private. Anyone with the token can resolve or delete this discussion.
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.