Merge branch 'master' into lxc_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) --exclude sshsh ./ $(NODEURL)/usr/share/NodeManager/
62         +$(RSYNC) ./sshsh $(NODEURL)/bin/
63         +$(RSYNC) ./initscripts/nm $(NODEURL)/etc/init.d/nm
64         ssh -i $(NODE).key.rsa root@$(NODE) service nm restart
65 endif
66
67 ### fetching the key
68
69 TESTMASTER ?= testmaster.onelab.eu
70
71 ifdef BUILD
72 KEYURL:=root@$(TESTMASTER):$(BUILD)/keys/key_admin.rsa
73 endif
74
75 key: $(NODE).key.rsa
76
77 $(NODE).key.rsa:
78 ifeq (,$(KEYURL))
79         @echo "sync: fetching $@ - You must define TESTMASTER, BUILD and NODE on the command line"
80         @echo "  e.g. make sync TESTMASTER=testmaster.onelab.eu BUILD=2010.01.22--1l-f8-32 NODE=vnode01.inria.fr"
81         @echo "  note that for now all test builds use the same key, so any BUILD would do"
82         @exit 1
83 else
84         @echo "FETCHING key"
85         +scp $(KEYURL) $@
86 endif
87
88 ### utility - find out the node name for a given BUILD
89
90 ifdef BUILD
91 NODEIPCOMMAND:=ssh root@$(TESTMASTER) cat $(BUILD)/arg-ips-node
92 endif
93
94 nodename:
95 ifeq (,$(NODEIPCOMMAND))
96         @echo "nodename: You must define TESTMASTER and BUILD on the command line"
97 else
98         $(NODEIPCOMMAND)
99 endif