Merge branch 'devel' of ssh://git.planet-lab.org/git/nodemanager into devel
[nodemanager.git] / Makefile
1 #
2 # Node Manager Makefile
3 #
4 # David Eisenstat <deisenst@cs.princeton.edu>
5 # Mark Huang <mlhuang@cs.princeton.edu>
6 # Copyright (C) 2006 The Trustees of Princeton University
7 #
8 # $Id: Makefile,v 1.2 2006/11/13 20:04:44 mlhuang Exp $
9 #
10
11 # autoconf compatible variables
12 datadir := /usr/share
13 bindir := /usr/bin
14
15 all: forward_api_calls
16         python setup.py build
17
18 forward_api_calls: forward_api_calls.c
19         $(CC) -Wall -Os -o $@ $?
20         strip $@
21
22 install:
23         python setup.py install \
24             --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
25             --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
26             --install-scripts=$(DESTDIR)/$(bindir)
27         install -m 444 README $(DESTDIR)/$(datadir)/NodeManager
28
29 clean:
30         python setup.py clean
31         rm -f forward_api_calls *.pyc build
32
33 .PHONY: all install clean
34
35 ##########
36 tags:
37         (find . '(' -name '*.py' -o -name '*.c' -o -name '*.spec' ')' ; ls initscripts/*) | xargs etags 
38
39 .PHONY: tags
40
41 ########## sync
42 # for use with the test framework; push local stuff on a test node
43 # make sync NODE=vnode01.inria.fr
44 # specify TESTMASTER and BUILD if the key is not available yet
45
46 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' 
47 RSYNC_EXCLUDES          := --exclude .git  --exclude .svn --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
48 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
49 RSYNC                   := rsync -e "ssh -i $(NODE).key.rsa" -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
50
51 ifdef NODE
52 NODEURL:=root@$(NODE):/
53 endif
54
55 sync: $(NODE).key.rsa
56 ifeq (,$(NODEURL))
57         @echo "sync: You must define NODE on the command line"
58         @echo "  e.g. make sync NODE=vnode01.inria.fr"
59         @exit 1
60 else
61         +$(RSYNC) ./ $(NODEURL)/usr/share/NodeManager/
62         +$(RSYNC) ./initscripts/nm $(NODEURL)/etc/init.d/nm
63         ssh -i $(NODE).key.rsa root@$(NODE) service nm restart
64 endif
65
66 ### fetching the key
67
68 TESTMASTER ?= testmaster.onelab.eu
69
70 ifdef BUILD
71 KEYURL:=root@$(TESTMASTER):$(BUILD)/keys/key1.rsa
72 endif
73
74 key: $(NODE).key.rsa
75
76 $(NODE).key.rsa:
77 ifeq (,$(KEYURL))
78         @echo "sync: fetching $@ - You must define TESTMASTER, BUILD and NODE on the command line"
79         @echo "  e.g. make sync TESTMASTER=testmaster.onelab.eu BUILD=2010.01.22--1l-f8-32 NODE=vnode01.inria.fr"
80         @echo "  note that for now all test builds use the same key, so any BUILD would do"
81         @exit 1
82 else
83         @echo "FETCHING key"
84         +scp $(KEYURL) $@
85 endif
86
87 ### utility - find out the node name for a given BUILD
88
89 ifdef BUILD
90 NODEIPCOMMAND:=ssh root@$(TESTMASTER) cat $(BUILD)/arg-ips-node
91 endif
92
93 nodename:
94 ifeq (,$(NODEIPCOMMAND))
95         @echo "nodename: You must define TESTMASTER and BUILD on the command line"
96 else
97         $(NODEIPCOMMAND)
98 endif