Bump tag level
[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
9 # autoconf compatible variables
10 datadir := /usr/share
11 bindir := /usr/bin
12
13 lib: forward_api_calls
14         python setup-lib.py build
15
16 vs: 
17         python setup-vs.py build
18
19 lxc: 
20         python setup-lxc.py build
21
22 forward_api_calls: forward_api_calls.c
23         $(CC) -Wall -Os -o $@ $?
24         strip $@
25
26 install-lib:
27         python setup-lib.py install \
28             --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
29             --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
30             --install-scripts=$(DESTDIR)/$(bindir)
31         install -m 444 README $(DESTDIR)/$(datadir)/NodeManager
32
33 install-vs:
34         python setup-vs.py install \
35             --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
36             --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
37             --install-scripts=$(DESTDIR)/$(bindir)
38         install -m 444 README $(DESTDIR)/$(datadir)/NodeManager
39
40 install-lxc:
41         python setup-lxc.py install \
42             --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
43             --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
44             --install-scripts=$(DESTDIR)/$(bindir)
45         install -m 444 README $(DESTDIR)/$(datadir)/NodeManager
46
47 clean:
48         python setup-lib.py clean
49         python setup-vs.py clean
50         python setup-lxc.py clean
51         rm -f forward_api_calls *.pyc build
52
53 .PHONY: all install clean
54
55 ##########
56 tags:
57         (find . '(' -name '*.py' -o -name '*.c' -o -name '*.spec' ')' ; ls initscripts/*) | xargs etags 
58
59 .PHONY: tags
60
61 ########## sync
62 # for use with the test framework; push local stuff on a test node
63 # make sync NODE=vnode01.inria.fr
64 # specify TESTMASTER and BUILD if the key is not available yet
65
66 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' 
67 RSYNC_EXCLUDES          := --exclude .git  --exclude .svn --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
68 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
69 RSYNC                   := rsync -e "ssh -i $(NODE).key.rsa" -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
70
71 ifdef NODE
72 NODEURL:=root@$(NODE):/
73 endif
74
75 sync: $(NODE).key.rsa
76 ifeq (,$(NODEURL))
77         @echo "sync: You must define NODE on the command line"
78         @echo "  e.g. make sync NODE=vnode01.inria.fr"
79         @exit 1
80 else
81         +$(RSYNC) --exclude sshsh ./ $(NODEURL)/usr/share/NodeManager/
82         +$(RSYNC) ./sshsh $(NODEURL)/bin/
83         +$(RSYNC) ./initscripts/nm $(NODEURL)/etc/init.d/nm
84         ssh -i $(NODE).key.rsa root@$(NODE) service nm restart
85 endif
86
87 ### fetching the key
88
89 TESTMASTER ?= testmaster.onelab.eu
90
91 ifdef BUILD
92 KEYURL:=root@$(TESTMASTER):$(BUILD)/keys/key_admin.rsa
93 endif
94
95 key: $(NODE).key.rsa
96
97 $(NODE).key.rsa:
98 ifeq (,$(KEYURL))
99         @echo "sync: fetching $@ - You must define TESTMASTER, BUILD and NODE on the command line"
100         @echo "  e.g. make sync TESTMASTER=testmaster.onelab.eu BUILD=2010.01.22--1l-f8-32 NODE=vnode01.inria.fr"
101         @echo "  note that for now all test builds use the same key, so any BUILD would do"
102         @exit 1
103 else
104         @echo "FETCHING key"
105         +scp $(KEYURL) $@
106 endif
107
108 ### utility - find out the node name for a given BUILD
109
110 ifdef BUILD
111 NODEIPCOMMAND:=ssh root@$(TESTMASTER) cat $(BUILD)/arg-ips-node
112 endif
113
114 nodename:
115 ifeq (,$(NODEIPCOMMAND))
116         @echo "nodename: You must define TESTMASTER and BUILD on the command line"
117 else
118         $(NODEIPCOMMAND)
119 endif