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