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