tweak privatebridge to remove exception message when ovs is not installed - prints...
[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
39 # might be better in setup.py ?
40 # NOTE: the sliver-initscripts/ and sliver-systemd stuff, being, well, for slivers,
41 # need to ship on all nodes regardless of WITH_INIT and WITH_SYSTEMD that 
42 # impacts how nodemanager itself gets started
43 install-miscell:
44         install -d -m 755 $(DESTDIR)/var/lib/nodemanager
45         install -D -m 644 /dev/null $(DESTDIR)/etc/sysconfig/nodemanager 
46         install -D -m 444 README $(DESTDIR)/$(datadir)/NodeManager/README
47         install -D -m 644 logrotate/nodemanager $(DESTDIR)/etc/logrotate.d/nodemanager
48         mkdir -p $(DESTDIR)/$(datadir)/NodeManager/sliver-initscripts
49         rsync -av sliver-initscripts/ $(DESTDIR)/$(datadir)/NodeManager/sliver-initscripts/
50         chmod 755 $(DESTDIR)/$(datadir)/NodeManager/sliver-initscripts/
51         mkdir -p $(DESTDIR)/$(datadir)/NodeManager/sliver-systemd
52         rsync -av sliver-systemd/ $(DESTDIR)/$(datadir)/NodeManager/sliver-systemd/
53         chmod 755 $(DESTDIR)/$(datadir)/NodeManager/sliver-systemd/
54
55 # this now is for the startup of nodemanager itself
56 ifneq "$(WITH_SYSTEMD)" ""
57 install-startup: install-systemd
58 endif
59 ifneq "$(WITH_INIT)" ""
60 install-startup: install-init
61 endif
62
63 install-init:
64         mkdir -p $(DESTDIR)$(initdir)
65         chmod 755 initscripts/*
66         rsync -av initscripts/ $(DESTDIR)$(initdir)/
67
68 install-systemd:
69         mkdir -p $(DESTDIR)/$(systemddir)
70         rsync -av systemd/ $(DESTDIR)/$(systemddir)
71
72 #################### clean
73 clean:
74         python setup.py clean
75         rm -f forward_api_calls *.pyc build
76
77 .PHONY: all install clean
78
79 #################### debian-related
80 # This is called from the build with the following variables set 
81 # (see build/Makefile and target_debian)
82 # (.) RPMTARBALL
83 # (.) RPMVERSION
84 # (.) RPMRELEASE
85 # (.) RPMNAME
86 DEBVERSION=$(RPMVERSION).$(RPMRELEASE)
87 DEBTARBALL=../$(RPMNAME)_$(DEBVERSION).orig.tar.bz2
88 DATE=$(shell date -u +"%a, %d %b %Y %T")
89 force:
90
91 debian: DESTDIR=debian/tmp
92 debian: forward_api_calls install debian/changelog debian.source debian.package
93
94 debian/changelog: debian/changelog.in
95         sed -e "s|@VERSION@|$(DEBVERSION)|" -e "s|@DATE@|$(DATE)|" debian/changelog.in > debian/changelog
96
97 debian.source: force 
98         rsync -a $(RPMTARBALL) $(DEBTARBALL)
99
100 debian.package:
101         debuild --set-envvar PREFIX=/usr -uc -us -b
102
103 debian.clean:
104         $(MAKE) -f debian/rules clean
105         rm -rf build/ MANIFEST ../*.tar.gz ../*.dsc ../*.build
106         find . -name '*.pyc' -delete
107
108 ################################################## devel-oriented
109 tags:
110         (find . '(' -name '*.py' -o -name '*.c' -o -name '*.spec' ')' ; ls initscripts/*) | xargs etags 
111
112 .PHONY: tags
113
114 ########## sync
115 # for use with the test framework; push local stuff on a test node
116 # howto use: go on testmaster in the build you want to use and just run
117 # $ exp
118 # cut'n paste the result in a terminal in your working dir, e.g. (although all are not required)
119 # $ export BUILD=2013.07.02--lxc18
120 # $ export PLCHOSTLXC=gotan.pl.sophia.inria.fr
121 # $ export GUESTNAME=2013.07.02--lxc18-1-vplc01
122 # $ export GUESTHOSTNAME=vplc01.pl.sophia.inria.fr
123 # $ export KVMHOST=kvm64-6.pl.sophia.inria.fr
124 # $ export NODE=vnode01.pl.sophia.inria.fr
125 # and then just run
126 # $ make sync
127
128 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' 
129 RSYNC_EXCLUDES          := --exclude .git  --exclude .svn --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
130 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
131 RSYNC                   := rsync -e "ssh -i $(NODE).key.rsa" -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
132
133 ifdef NODE
134 NODEURL:=root@$(NODE):/
135 endif
136
137 # this is for lxc only, we need to exclude the vs stuff that otherwise messes up everything on node
138 # keep this in sync with setup-vs.spec
139 LXC_EXCLUDES= --exclude sliver_vs.py --exclude coresched_vs.py
140
141 # run with make SYNC_RESTART=false if you want to skip restarting nm
142 SYNC_RESTART=true
143
144 sync:synclxc
145
146 synclxc: $(NODE).key.rsa
147 ifeq (,$(NODEURL))
148         @echo "sync: You must define NODE on the command line"
149         @echo "  e.g. make sync NODE=vnode01.inria.fr"
150         @exit 1
151 else
152         @echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
153         @echo WARNING : this target might not be very reliable - use with care
154         @echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
155         +$(RSYNC) $(LXC_EXCLUDES) --delete-excluded ./ $(NODEURL)/usr/share/NodeManager/
156 #       +$(RSYNC) ./initscripts/ $(NODEURL)/etc/init.d/
157         +$(RSYNC) ./systemd/ $(NODEURL)/usr/lib/systemd/system/
158         -$(SYNC_RESTART) && { ssh -i $(NODE).key.rsa root@$(NODE) service nm restart ; } ||:
159 endif
160
161 ### fetching the key
162
163 TESTMASTER ?= testmaster.onelab.eu
164
165 ifdef BUILD
166 KEYURL:=root@$(TESTMASTER):$(BUILD)/keys/key_admin.rsa
167 endif
168
169 key: $(NODE).key.rsa
170
171 $(NODE).key.rsa:
172 ifeq (,$(KEYURL))
173         @echo "sync: fetching $@ - You must define TESTMASTER, BUILD and NODE on the command line"
174         @echo "  e.g. make sync TESTMASTER=testmaster.onelab.eu BUILD=2010.01.22--1l-f8-32 NODE=vnode01.inria.fr"
175         @echo "  note that for now all test builds use the same key, so any BUILD would do"
176         @exit 1
177 else
178         @echo "FETCHING key"
179         +scp $(KEYURL) $@
180 endif