keep it simple
[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 # call with either WITH_SYSTEMD=true or WITH_INIT=true
13 initdir=/etc/rc.d/init.d
14 systemddir := /usr/lib/systemd/system
15
16 ####################
17 lib: forward_api_calls
18         python setup-lib.py build
19
20 vs: 
21         python setup-vs.py build
22
23 lxc: 
24         python setup-lxc.py build
25
26 forward_api_calls: forward_api_calls.c
27         $(CC) -Wall -Os -o $@ $?
28         strip $@
29
30 #################### install
31 install-lib: install-miscell install-startup
32         python setup-lib.py install \
33                 --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
34                 --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
35                 --install-scripts=$(DESTDIR)/$(bindir)
36
37 # might be better in setup.py ?
38 install-miscell:
39         install -d -m 755 $(DESTDIR)/var/lib/nodemanager
40         install -D -m 444 README $(DESTDIR)/$(datadir)/NodeManager/README
41         install -D -m 644 logrotate/nodemanager $(DESTDIR)/etc/logrotate.d/nodemanager
42         install -D -m 755 sshsh $(DESTDIR)/bin/sshsh
43         mkdir -p $(DESTDIR)/$(datadir)/NodeManager/sliver-initscripts
44         rsync -av sliver-initscripts/ $(DESTDIR)/$(datadir)/NodeManager/sliver-initscripts/
45         chmod 755 $(DESTDIR)/$(datadir)/NodeManager/sliver-initscripts/
46
47 ifneq "$(WITH_SYSTEMD)" ""
48 install-startup: install-systemd
49 endif
50 ifneq "$(WITH_INIT)" ""
51 install-startup: install-init
52 endif
53
54 install-init:
55         mkdir -p $(DESTDIR)$(initdir)
56         chmod 755 initscripts/*
57         rsync -av initscripts/ $(DESTDIR)$(initdir)/
58
59 install-systemd:
60         mkdir -p $(DESTDIR)/$(systemddir)
61         rsync -av systemd/ $(DESTDIR)/$(systemddir)
62
63 install-vs:
64         python setup-vs.py install \
65                 --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
66                 --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
67                 --install-scripts=$(DESTDIR)/$(bindir)
68         install -m 444 README $(DESTDIR)/$(datadir)/NodeManager
69
70 install-lxc:
71         python setup-lxc.py install \
72                 --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
73                 --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
74                 --install-scripts=$(DESTDIR)/$(bindir)
75         install -m 444 README $(DESTDIR)/$(datadir)/NodeManager
76
77 #################### clean
78 clean:
79         python setup-lib.py clean
80         python setup-vs.py clean
81         python setup-lxc.py clean
82         rm -f forward_api_calls *.pyc build
83
84 .PHONY: all install clean
85
86 ##########
87 tags:
88         (find . '(' -name '*.py' -o -name '*.c' -o -name '*.spec' ')' ; ls initscripts/*) | xargs etags 
89
90 .PHONY: tags
91
92 ########## sync
93 # for use with the test framework; push local stuff on a test node
94 # howto use: go on testmaster in the build you want to use and just run
95 # $ exp
96 # cut'n paste the result in a terminal in your working dir, e.g. (although all are not required)
97 # $ export BUILD=2013.07.02--lxc18
98 # $ export PLCHOSTLXC=gotan.pl.sophia.inria.fr
99 # $ export GUESTNAME=2013.07.02--lxc18-1-vplc01
100 # $ export GUESTHOSTNAME=vplc01.pl.sophia.inria.fr
101 # $ export KVMHOST=kvm64-6.pl.sophia.inria.fr
102 # $ export NODE=vnode01.pl.sophia.inria.fr
103 # and then just run
104 # $ make sync
105
106 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' 
107 RSYNC_EXCLUDES          := --exclude .git  --exclude .svn --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
108 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
109 RSYNC                   := rsync -e "ssh -i $(NODE).key.rsa" -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
110
111 ifdef NODE
112 NODEURL:=root@$(NODE):/
113 endif
114
115 # this is for lxc only, we need to exclude the vs stuff that otherwise messes up everything on node
116 # keep this in sync with setup-vs.spec
117 LXC_EXCLUDES= --exclude sliver_vs.py --exclude coresched_vs.py
118
119 sync:synclxc
120
121 synclxc: $(NODE).key.rsa
122 ifeq (,$(NODEURL))
123         @echo "sync: You must define NODE on the command line"
124         @echo "  e.g. make sync NODE=vnode01.inria.fr"
125         @exit 1
126 else
127         @echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
128         @echo WARNING : this target might not be very reliable - use with care
129         @echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
130         +$(RSYNC) --exclude sshsh $(LXC_EXCLUDES) --delete-excluded ./ $(NODEURL)/usr/share/NodeManager/
131         +$(RSYNC) ./sshsh $(NODEURL)/bin/
132 #       +$(RSYNC) ./initscripts/ $(NODEURL)/etc/init.d/
133         +$(RSYNC) ./systemd/ $(NODEURL)/usr/lib/systemd/system/
134 #       ssh -i $(NODE).key.rsa root@$(NODE) service nm restart
135 endif
136
137 ### fetching the key
138
139 TESTMASTER ?= testmaster.onelab.eu
140
141 ifdef BUILD
142 KEYURL:=root@$(TESTMASTER):$(BUILD)/keys/key_admin.rsa
143 endif
144
145 key: $(NODE).key.rsa
146
147 $(NODE).key.rsa:
148 ifeq (,$(KEYURL))
149         @echo "sync: fetching $@ - You must define TESTMASTER, BUILD and NODE on the command line"
150         @echo "  e.g. make sync TESTMASTER=testmaster.onelab.eu BUILD=2010.01.22--1l-f8-32 NODE=vnode01.inria.fr"
151         @echo "  note that for now all test builds use the same key, so any BUILD would do"
152         @exit 1
153 else
154         @echo "FETCHING key"
155         +scp $(KEYURL) $@
156 endif