sync revisited
[myplc.git] / Makefile
1
2 # $Id$
3 #
4
5 BINARIES = plc-config plc-config-tty db-config dns-config \
6         clean-empty-dirs.py mtail.py \
7         plc-check-ssl-peering.py plc-map.py plc-kml.py plc-orphan-accounts.py \
8         support-scripts/renew_reminder.py support-scripts/gen_aliases.py 
9 INIT_SCRIPTS = api bootcd bootmanager db dns functions gpg httpd mail network packages postgresql ssh ssl
10
11 INITS=$(addprefix plc.d/,$(INIT_SCRIPTS))
12
13 ##########
14 tags:
15         find . -type f | egrep -v '.svn/|~$$' | xargs etags
16
17 .PHONY: tags
18
19 ########## sync
20 # 2 forms are supported
21 # (*) if your plc root context has direct ssh access:
22 # make sync PLC=private.one-lab.org
23 # (*) otherwise, entering through the root context
24 # make sync PLCHOST=testbox1.inria.fr GUEST=vplc03.inria.fr
25
26 ifdef GUEST
27 ifdef PLCHOST
28 SSHURL:=root@$(PLCHOST):/vservers/$(GUEST)
29 SSHCOMMAND:=ssh root@$(PLCHOST) vserver $(GUEST)
30 endif
31 endif
32 ifdef PLC
33 SSHURL:=root@$(PLC):/
34 SSHCOMMAND:=ssh root@$(PLC)
35 endif
36
37 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' 
38 RSYNC_EXCLUDES          := --exclude .svn --exclude CVS --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
39 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
40 RSYNC                   := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
41
42 sync:
43 ifeq (,$(SSHURL))
44         @echo "sync: You must define, either PLC, or PLCHOST & GUEST, on the command line"
45         @echo "  e.g. make sync PLC=private.one-lab.org"
46         @echo "  or   make sync PLCHOST=testbox1.inria.fr GUEST=vplc03.inria.fr"
47         @exit 1
48 else
49         +$(RSYNC) plc.init $(SSHURL)/etc/init.d/plc
50         +$(RSYNC) $(BINARIES) $(SSHURL)/usr/bin
51         +$(RSYNC) $(INITS) $(SSHURL)/etc/plc.d
52         +$(RSYNC) plc_config.py $(SSHURL)/usr/lib/python2.5/site-packages/plc_config.py
53         +$(RSYNC) default_config.xml $(SSHURL)/etc/planetlab/default_config.xml
54         @echo XXXXXXXX you might need to run ssh root@$(PLC) service plc start 
55 endif
56
57 #################### convenience, for debugging only
58 # make +foo : prints the value of $(foo)
59 # make ++foo : idem but verbose, i.e. foo=$(foo)
60 ++%: varname=$(subst +,,$@)
61 ++%:
62         @echo "$(varname)=$($(varname))"
63 +%: varname=$(subst +,,$@)
64 +%:
65         @echo "$($(varname))"
66