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