make sync to push on a work/test plc
[sfa.git] / Makefile
1 #
2 ## (Re)builds Python metafile (__init__.py) and documentation
3
4 # overwritten by the specfile
5 DESTDIR="/"
6
7 init := geni/__init__.py geni/util/__init__.py geni/methods/__init__.py 
8 subdirs := keyconvert #pyOpenSSL-0.9
9
10 all: install
11
12 install: $(init) $(subdirs) install-python
13
14 install-python:
15         python setup.py install --root=$(DESTDIR) --record=GENI_INSTALLED_FILES
16
17 $(subdirs): $(init)
18
19 $(subdirs): %:
20         $(MAKE) -C $@
21
22 clean:
23         python setup.py clean
24         for i in $(subdirs); do make -C $$i clean ; done
25
26 index: $(init)
27
28 index-clean:
29         rm $(init)
30
31 .phony: all install install-python force clean index $(subdirs)
32
33 force:
34
35 # are the .java files used ?
36 tags:   
37         find . -name '*.py' -o -name '*.sh' -o -name '*.ecore'  | grep -v '/\.svn/' | xargs etags
38
39
40
41 ########## indexes
42 geni/__init__.py:
43         (echo '## Please use make index to update this file' ; echo 'all = """' ; cd geni; ls -1 *.py | grep -v __init__ | sed -e 's,.py$$,,' ; echo '""".split()') > $@
44
45 geni/methods/__init__.py:
46         (echo '## Please use make index to update this file' ; echo 'all = """' ; cd geni/methods; ls -1 *.py | grep -v __init__ | sed -e 's,.py$$,,' ; echo '""".split()') > $@
47
48 geni/util/__init__.py:
49         (echo '## Please use make index to update this file' ; echo 'all = """' ; cd geni/util; ls -1 *.py | grep -v __init__ | sed -e 's,.py$$,,' ; echo '""".split()') > $@
50
51 geni_now := $(sort $(shell fgrep -v '"' geni/__init__.py 2>/dev/null))
52 # what should be declared
53 geni_paths := $(filter-out %/__init__.py, $(wildcard geni/*.py))
54 geni_files := $(sort $(notdir $(geni_paths:.py=)))
55 ifneq ($(geni_now), $(geni_files))
56 geni/__init__.py: force
57 endif
58
59 methods_now := $(sort $(shell fgrep -v '"' geni/methods/__init__.py 2>/dev/null))
60 # what should be declared
61 method_paths := $(filter-out %/__init__.py, $(wildcard geni/methods/*.py))
62 method_files := $(sort $(notdir $(method_paths:.py=)))
63 ifneq ($(methods_now), $(methods_files))
64 geni/methods/__init__.py: force
65 endif
66
67 util_now := $(sort $(shell fgrep -v '"' geni/util/__init__.py 2>/dev/null))
68 # what should be declared
69 util_paths := $(filter-out %/__init__.py, $(wildcard geni/util/*.py))
70 util_files := $(sort $(notdir $(util_paths:.py=)))
71 ifneq ($(util_now), $(util_files))
72 geni/util/__init__.py: force
73 endif
74
75 ########## sync
76 # 2 forms are supported
77 # (*) if your plc root context has direct ssh access:
78 # make sync PLC=private.one-lab.org
79 # (*) otherwise, entering through the root context
80 # make sync PLCHOST=testbox1.inria.fr GUEST=vplc03.inria.fr
81
82 ifdef GUEST
83 ifdef PLCHOST
84 SSHURL:=root@$(PLCHOST):/vservers/$(GUEST)
85 SSHCOMMAND:=ssh root@$(PLCHOST) vserver $(GUEST)
86 endif
87 endif
88 ifdef PLC
89 SSHURL:=root@$(PLC):/
90 SSHCOMMAND:=ssh root@$(PLC)
91 endif
92
93 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' 
94 RSYNC_EXCLUDES          := --exclude .svn --exclude CVS --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
95 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
96 RSYNC                   := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
97
98 sync:
99 ifeq (,$(SSHURL))
100         @echo "sync: You must define, either PLC, or PLCHOST & GUEST, on the command line"
101         @echo "  e.g. make sync PLC=private.one-lab.org"
102         @echo "  or   make sync PLCHOST=testbox1.inria.fr GUEST=vplc03.inria.fr"
103         @exit 1
104 else
105         +$(RSYNC) ./geni/ $(SSHURL)/usr/lib/python2.5/site-packages/geni/
106         +$(RSYNC) geni-config-tty $(SSHURL)/usr/bin
107 endif
108