help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ssh, $(MAKE) and -n weirdness


From: Martin d'Anjou
Subject: Re: ssh, $(MAKE) and -n weirdness
Date: Tue, 15 Jul 2008 10:18:55 -0400 (EDT)
User-agent: Alpine 1.00 (LRH 882 2007-12-20)

$ 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]