cleanup
[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: index
30
31 python-install:
32         python setup.py install --root=$(DESTDIR) --record=GENI_INSTALLED_FILES
33
34 python-clean:
35         python setup.py clean
36         rm $(init)
37
38 .PHONY: python python-install python-clean
39 ##########
40
41 # are the .java files used ?
42 tags:   
43         find . -name '*.py' -o -name '*.sh' -o -name '*.ecore'  | grep -v '/\.svn/' | xargs etags
44 .PHONY: tags
45
46
47 ########## indexes
48 init := geni/__init__.py geni/util/__init__.py geni/methods/__init__.py 
49
50 force:
51 .PHONY: force 
52
53 index: $(init)
54 .PHONY: index
55
56 geni/__init__.py:
57         (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()') > $@
58
59 geni/methods/__init__.py:
60         (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()') > $@
61
62 geni/util/__init__.py:
63         (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()') > $@
64
65 geni_now := $(sort $(shell fgrep -v '"' geni/__init__.py 2>/dev/null))
66 # what should be declared
67 geni_paths := $(filter-out %/__init__.py, $(wildcard geni/*.py))
68 geni_files := $(sort $(notdir $(geni_paths:.py=)))
69 ifneq ($(geni_now), $(geni_files))
70 geni/__init__.py: force
71 endif
72
73 methods_now := $(sort $(shell fgrep -v '"' geni/methods/__init__.py 2>/dev/null))
74 # what should be declared
75 method_paths := $(filter-out %/__init__.py, $(wildcard geni/methods/*.py))
76 method_files := $(sort $(notdir $(method_paths:.py=)))
77 ifneq ($(methods_now), $(methods_files))
78 geni/methods/__init__.py: force
79 endif
80
81 util_now := $(sort $(shell fgrep -v '"' geni/util/__init__.py 2>/dev/null))
82 # what should be declared
83 util_paths := $(filter-out %/__init__.py, $(wildcard geni/util/*.py))
84 util_files := $(sort $(notdir $(util_paths:.py=)))
85 ifneq ($(util_now), $(util_files))
86 geni/util/__init__.py: force
87 endif
88
89 ########## sync
90 # 2 forms are supported
91 # (*) if your plc root context has direct ssh access:
92 # make sync PLC=private.one-lab.org
93 # (*) otherwise, entering through the root context
94 # make sync PLCHOST=testbox1.inria.fr GUEST=vplc03.inria.fr
95
96 ifdef GUEST
97 ifdef PLCHOST
98 SSHURL:=root@$(PLCHOST):/vservers/$(GUEST)
99 SSHCOMMAND:=ssh root@$(PLCHOST) vserver $(GUEST)
100 endif
101 endif
102 ifdef PLC
103 SSHURL:=root@$(PLC):/
104 SSHCOMMAND:=ssh root@$(PLC)
105 endif
106
107 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' 
108 RSYNC_EXCLUDES          := --exclude .svn --exclude CVS --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
109 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
110 RSYNC                   := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
111
112 sync:
113 ifeq (,$(SSHURL))
114         @echo "sync: You must define, either PLC, or PLCHOST & GUEST, on the command line"
115         @echo "  e.g. make sync PLC=private.one-lab.org"
116         @echo "  or   make sync PLCHOST=testbox1.inria.fr GUEST=vplc03.inria.fr"
117         @exit 1
118 else
119         +$(RSYNC) ./geni/ $(SSHURL)/usr/lib/python2.5/site-packages/geni/
120         +$(RSYNC) ./config/geni-config-tty $(SSHURL)/usr/bin
121         $(SSHCOMMAND) exec service geni restart
122 endif
123
124 .PHONY: sync
125 ##########