$ cat makefile
remote=localhost
remote1:
       ssh $(remote) "cd $(PWD) && $(MAKE) -f makefile this"
remote2:
       ssh $(remote) "cd $(PWD) && make -f makefile this"
this:
       @echo This is done!

$ make remote1 -n
ssh localhost "cd /home/me && make -f makefile this"
This is done!
$ make remote2 -n
ssh localhost "cd /home/me && make -f makefile this"
$

What I do not understand is why "remote1" is built even though I pass -n?


This is documented. See GNU Make Manual section 5.7.1: "Command lines
containing MAKE are executed normally despite the presence of a flag that
causes most commands not to be run".

True. I wanted to point out that in building remote1, the -n flag is not passed to the submake, but now I understand that it is due to the fact it is in the ssh subshell:

  $ make remote1 -n
  ssh localhost "cd /home/me && make this"
  This is done!

Instead of this:

  $ make remote1 -n
  ssh localhost "cd /home/me && make this"
  echo This is done!

However, if I have this makefile instead:

  $ cat makefile
  remote=localhost
  remote1:
         ssh $(remote) "cd $(PWD) && $(MAKE) -f makefile this MAKEFLAGS=$(MAKEFLAGS) 
MAKEOVERRIDES=$(MAKEOVERRIDES)"
  this:
         @echo This is done!

Then I get the desired effect of propagating the '-n' and command line
variables through the subshell (ssh in this case). I am sure this will come back to bite me, but I don't see how yet.

Martin


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to