I am working on the Makefile someone else in my lab wrote, and I see a command called true in some rules:
other_rule_A: YYY force_it
....
other_rule_B: XXX force_it
....
force_it:
true
What does true mean here? Is it a command run by the subshell? What would happen if I replace it by false? Is true a binary invoked by the shell?
For reference, I found this other question in Stackoverflow: Why do makefiles sometimes have ‘true ‘ as part of the build script?, but I don’t think command is related to the command they cover in that thread.
trueis a command (usually the executable/bin/true, but often also a shell builtin) that does nothing and returns success. If you were to replace it withfalse, theforce_it:rule would always fail and thus stop the make process at that point.The difference between having this
trueaction and having aforce_it:rule with no action is that with no action, there might be some otherforce_it:rule with actions added elsewhere in the makefile. With atrueaction, you know that there can be no other action — if another action was added, you’d get a make error.