Created
June 25, 2011 03:31
-
-
Save tlrobinson/1046105 to your computer and use it in GitHub Desktop.
Remote Makefiles fun
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ make hello | |
hello world from localhost! | |
$ make foohost remote-hello | |
make: `foohost' is up to date. | |
make: Entering directory `/home/foouser/tmp' | |
hello world from foohost! | |
make: Leaving directory `/home/foouser/tmp' | |
$ make barhost remote-hello | |
make: `barhost' is up to date. | |
make: Entering directory `/home/baruser/tmp' | |
hello world from barhost! | |
make: Leaving directory `/home/baruser/tmp' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MAKEFILE=$(lastword $(MAKEFILE_LIST)) | |
REMOTE?=$(REMOTE_USER)@$(REMOTE_HOST) | |
REMOTE_SSH?=ssh -p $(REMOTE_PORT) | |
REMOTE_SHELL?=$(REMOTE_SSH) $(REMOTE) $(REMOTE_LOGIN) | |
REMOTE_MAKE?=cat $(MAKEFILE) | $(REMOTE_SHELL) make -f /dev/stdin -C $(REMOTE_BASE) | |
# LOCAL COMMANDS: | |
hello: | |
@echo hello world from $(shell hostname)! | |
# REMOTE COMMANDS: | |
remote-%: | |
@$(REMOTE_MAKE) $* | |
# SERVERS: | |
foohost: | |
$(eval REMOTE_HOST := foohost) | |
$(eval REMOTE_PORT := 22) | |
$(eval REMOTE_USER := foouser) | |
$(eval REMOTE_BASE := /home/foouser/tmp) | |
barhost: | |
$(eval REMOTE_HOST := barhost) | |
$(eval REMOTE_PORT := 22) | |
$(eval REMOTE_USER := baruser) | |
$(eval REMOTE_BASE := /home/baruser/tmp) |
@To1ne: thanks for the tip but I don't quite see how I can use that. I'm relying on being able to set the host properties in a separate target that gets run first.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You don't need to use eval.
You can use target specific variables instead.