making the source file executable under git was not enough, I suspect setup.py enforc...
[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 initdir=/etc/rc.d/init.d
13 systemddir := /usr/lib/systemd/system
14
15 # call with either WITH_SYSTEMD=true or WITH_INIT=true
16 # otherwise we try to guess some reasonable default
17 ifeq "$(WITH_INIT)$(WITH_SYSTEMD)" ""
18 ifeq "$(wildcard $systemddir/*)" ""
19 WITH_INIT=true
20 else
21 WITH_SYSTEMD=true
22 endif
23 endif
24 ####################
25 all: forward_api_calls
26         python setup.py build
27
28 forward_api_calls: forward_api_calls.c
29         $(CC) -Wall -Os -o $@ $?
30         strip $@
31
32 #################### install
33 install: install-miscell install-startup
34         python setup.py install \
35                 --install-purelib=$(DESTDIR)/$(datadir)/NodeManager \
36                 --install-platlib=$(DESTDIR)/$(datadir)/NodeManager \
37                 --install-scripts=$(DESTDIR)/$(bindir)
38         chmod +x $(DESTDIR)/$(datadir)/NodeManager/conf_files.py
39
40 # might be better in setup.py ?
41 # NOTE: the sliver-initscripts/ and sliver-systemd stuff, being, well, for slivers,
42 # need to ship on all nodes regardless of WITH_INIT and WITH_SYSTEMD that 
43 # impacts how nodemanager itself gets started
44 install-miscell:
45         install -d -m 755 $(DESTDIR)/var/lib/nodemanager
46         install -D -m 644 /dev/null $(DESTDIR)/etc/sysconfig/nodemanager 
47         install -D -m 444 README $(DESTDIR)/$(datadir)/NodeManager/README
48         install -D -m 644 logrotate/nodemanager $(DESTDIR)/etc/logrotate.d/nodemanager
49         mkdir -p $(DESTDIR)/$(datadir)/NodeManager/sliver-initscripts
50         rsync -av sliver-initscripts/ $(DESTDIR)/$(datadir)/NodeManager/sliver-initscripts/
51         chmod 755 $(DESTDIR)/$(datadir)/NodeManager/sliver-initscripts/
52         mkdir -p $(DESTDIR)/$(datadir)/NodeManager/sliver-systemd
53         rsync -av sliver-systemd/ $(DESTDIR)/$(datadir)/NodeManager/sliver-systemd/
54         chmod 755 $(DESTDIR)/$(datadir)/NodeManager/sliver-systemd/
55
56 # this now is for the startup of nodemanager itself
57 ifneq "$(WITH_SYSTEMD)" ""
58 install-startup: install-systemd
59 endif
60 ifneq "$(WITH_INIT)" ""
61 install-startup: install-init
62 endif
63
64 install-init:
65         mkdir -p $(DESTDIR)$(initdir)
66         chmod 755 initscripts/*
67         rsync -av initscripts/ $(DESTDIR)$(initdir)/
68
69 install-systemd:
70         mkdir -p $(DESTDIR)/$(systemddir)
71         rsync -av systemd/ $(DESTDIR)/$(systemddir)
72
73 #################### clean
74 clean:
75         python setup.py clean
76         rm -f forward_api_calls *.pyc build
77
78 .PHONY: all install clean
79
80 #################### debian-related
81 # This is called from the build with the following variables set 
82 # (see build/Makefile and target_debian)
83 # (.) RPMTARBALL
84 # (.) RPMVERSION
85 # (.) RPMRELEASE
86 # (.) RPMNAME
87 DEBVERSION=$(RPMVERSION).$(RPMRELEASE)
88 DEBTARBALL=../$(RPMNAME)_$(DEBVERSION).orig.tar.bz2
89 DATE=$(shell date -u +"%a, %d %b %Y %T")
90 force:
91
92 debian: DESTDIR=debian/tmp
93 debian: forward_api_calls install debian/changelog debian.source debian.package
94
95 debian/changelog: debian/changelog.in
96         sed -e "s|@VERSION@|$(DEBVERSION)|" -e "s|@DATE@|$(DATE)|" debian/changelog.in > debian/changelog
97
98 debian.source: force 
99         rsync -a $(RPMTARBALL) $(DEBTARBALL)
100
101 debian.package:
102         debuild --set-envvar PREFIX=/usr -uc -us -b
103
104 debian.clean:
105         $(MAKE) -f debian/rules clean
106         rm -rf build/ MANIFEST ../*.tar.gz ../*.dsc ../*.build
107         find . -name '*.pyc' -delete
108
109 ################################################## devel-oriented
110 tags:
111         git ls-files | xargs etags
112
113 .PHONY: tags
114
115 ########## sync
116 # for use with the test framework; push local stuff on a test node
117 # howto use: go on testmaster in the build you want to use and just run
118 # $ exp
119 # cut'n paste the result in a terminal in your working dir, e.g. (although all are not required)
120 # $ export BUILD=2013.07.02--lxc18
121 # $ export PLCHOSTLXC=gotan.pl.sophia.inria.fr
122 # $ export GUESTNAME=2013.07.02--lxc18-1-vplc01
123 # $ export GUESTHOSTNAME=vplc01.pl.sophia.inria.fr
124 # $ export KVMHOST=kvm64-6.pl.sophia.inria.fr
125 # $ export NODE=vnode01.pl.sophia.inria.fr
126 # and then just run
127 # $ make sync
128
129 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' 
130 RSYNC_EXCLUDES          := --exclude .git  --exclude .svn --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
131 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
132 RSYNC                   := rsync -e "ssh -i $(NODE).key.rsa" -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
133
134 ifdef NODE
135 NODEURL:=root@$(NODE):/
136 endif
137
138 # this is for lxc only, we need to exclude the vs stuff that otherwise messes up everything on node
139 # WARNING: keep this in sync with setup.spec
140 LXC_EXCLUDES= --exclude sliver_vs.py --exclude coresched_vs.py --exclude drl.py
141
142 # run with make SYNC_RESTART=false if you want to skip restarting nm
143 SYNC_RESTART=true
144
145 sync:synclxc
146
147 synclxc: $(NODE).key.rsa
148 ifeq (,$(NODEURL))
149         @echo "sync: You must define NODE on the command line"
150         @echo "  e.g. make sync NODE=vnode01.inria.fr"
151         @exit 1
152 else
153         @echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
154         @echo WARNING : this target might not be very reliable - use with care
155         @echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
156         +$(RSYNC) $(LXC_EXCLUDES) --delete-excluded ./ $(NODEURL)/usr/share/NodeManager/
157 #       +$(RSYNC) ./initscripts/ $(NODEURL)/etc/init.d/
158         +$(RSYNC) ./systemd/ $(NODEURL)/usr/lib/systemd/system/
159         -$(SYNC_RESTART) && { ssh -i $(NODE).key.rsa root@$(NODE) service nm restart ; } ||:
160 endif
161
162 # this is for vs only, we need to exclude the lxc stuff that otherwise messes up everything on node
163 # xxx keep this in sync with setup.spec
164 VS_EXCLUDES= --exclude sliver_libvirt.py --exclude sliver_lxc.py --exclude cgroups.py --exclude coresched_lxc.py --exclude privatebridge.py
165
166 syncvs: $(NODE).key.rsa
167 ifeq (,$(NODEURL))
168         @echo "syncvs: You must define NODE on the command line"
169         @echo "  e.g. make sync NODE=vnode01.inria.fr"
170         @exit 1
171 else
172         @echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
173         @echo WARNING : this target might not be very reliable - use with care
174         @echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
175         +$(RSYNC) $(VS_EXCLUDES) --delete-excluded ./ $(NODEURL)/usr/share/NodeManager/
176         +$(RSYNC) ./initscripts/ $(NODEURL)/etc/init.d/
177 #       +$(RSYNC) ./systemd/ $(NODEURL)/usr/lib/systemd/system/
178         -$(SYNC_RESTART) && { ssh -i $(NODE).key.rsa root@$(NODE) service nm restart ; } ||:
179 endif
180
181
182 ### fetching the key
183
184 TESTMASTER ?= testmaster.onelab.eu
185
186 ifdef BUILD
187 KEYURL:=root@$(TESTMASTER):$(BUILD)/keys/key_admin.rsa
188 endif
189
190 key: $(NODE).key.rsa
191
192 $(NODE).key.rsa:
193 ifeq (,$(KEYURL))
194         @echo "sync: fetching $@ - You must define TESTMASTER, BUILD and NODE on the command line"
195         @echo "  e.g. make sync TESTMASTER=testmaster.onelab.eu BUILD=2010.01.22--1l-f8-32 NODE=vnode01.inria.fr"
196         @echo "  note that for now all test builds use the same key, so any BUILD would do"
197         @exit 1
198 else
199         @echo "FETCHING key"
200         +scp $(KEYURL) $@
201 endif
202
203 ########## exp. too
204 SLICE=inri_sl1
205
206 syncvinit:
207         $(RSYNC) sliver-systemd/vinit.st* $(NODEURL)/vservers/$(SLICE)/usr/bin/
208         $(RSYNC) sliver-systemd/vinit.service $(NODEURL)/vservers/$(SLICE)/usr/lib/systemd/system/
209         echo "remember to run 'systemctl --system daemon-reload' within this slice"