Makefile: Better rule hacking for installation.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 6 Jun 2011 23:54:42 +0000 (00:54 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 6 Jun 2011 23:54:42 +0000 (00:54 +0100)
If I use static pattern rules, I can set them as phony.  But I must
exclude the local host rule.

Makefile

index 7596df7..8f918e5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -127,6 +127,7 @@ clean:; rm -f $(TARGETS) *.new
 
 ## The local machine doesn't want the complicated SSH stuff.
 THISHOST                = $(shell hostname)
+OTHERHOSTS              = $(filter-out $(THISHOST), $(HOSTS))
 
 ## Testing.
 check: $(THISHOST).sh
@@ -138,7 +139,7 @@ install/$(THISHOST): $(THISHOST).sh
        $(ROOT) ./$(THISHOST).sh replace
 
 ## Installation on a remote host.
-install/%: %.sh
+$(addprefix install/, $(OTHERHOSTS)): install/%: %.sh
        if [ "x$(SCRIPTS)" != x ]; then \
          for i in $(SCRIPTS); do \
            $(ROOT) scp $$i root@$*:$(sbindir)/$$i.new && \
@@ -148,12 +149,12 @@ install/%: %.sh
          done; \
        fi
        $(ROOT) scp $*.sh root@$*:$(FIREWALL).new
-       $(ROOT) ssh root@$* $(FIREWALL) remote-prepare
-       $(ROOT) ssh root@$* $(FIREWALL) remote-commit
+       $(ROOT) ssh root@$* $(FIREWALL).new remote-prepare
+       $(ROOT) ssh root@$* $(FIREWALL).new remote-commit
        $(ROOT) ssh root@$* rm -f $(FIREWALL).new
 
 ## General installation target.
 install: all install/$(THISHOST) $(addprefix install/,$(HOSTS))
-.PHONY: install install/$(THISHOST)
+.PHONY: install $(addprefix install/,$(HOSTS))
 
 ###----- That's all, folks --------------------------------------------------