I want to run my make task with .. make git pull
.PHONY: What do I put here? git pull ping suggests 3 targets right?
git pull:
~/ansible-ctrl/scripts/04-pull-git-latest.sh
ping:
~/ansible-ctrl/scripts/06-ping-ansible.sh
make git pull .. works sometimes, seems a bit hit and miss.
What do I put in the .PHONY bit?
Is this multiple word target approach valid?
Would problems arise if I used arguments?
Could I have a simple example that uses this approach correctly please (if there is such a thing)?
On the topic of rule syntax the GNU make manual reads:
The targets are file names, separated by spaces.
So in your example make sees two targets, git
and pull
. There was a question before on using spaces in a target. The answers however seem clunky (or don't even seem to work judging from the comments).
In general GNU make doesn't handle white spaces in filenames (and thus targets/prerequisites) well. This question (6 years ago!) references a bug about it, which still seems to be open.
My advice, just like @uzsolt pointed out in the comments, drop the space!
As @sycko points out, make sees two targets git
and pull
, which are jointly made by the actions that you provided (this behaviour is occasionally useful).
It seems worth pointing out, though, that the reason that it sometimes works when you type make git pull
, is that make
interprets that invocation as a request that it makes both the git
and the pull
targets (this, also, is occasionally useful). Thus make pull git
would probably have the same effect. That is, it only works by accident.
I'm not completely sure why this sometimes fails; but it's not too hard to confuse make's dependency logic, and I'm not particularly surprised at this construction behaving unpredictably.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With