Added the possibility for users to define a set of information fields
[sfa.git] / Makefile
1 #
2 ## (Re)builds Python metafile (__init__.py) 
3
4 # overwritten by the specfile
5 DESTDIR="/"
6
7 ##########
8 all: python wsdl 
9
10 install: python-install wsdl-install xmlbuilder-install tests-install
11
12 clean: python-clean wsdl-clean 
13
14 uninstall: python-uninstall tests-uninstall
15
16 .PHONY: all install clean uninstall
17
18 VERSIONTAG=should-be-redefined-by-specfile
19 SCMURL=should-be-redefined-by-specfile
20
21 ##########
22 python: version
23
24 version: sfa/util/version.py
25 sfa/util/version.py: sfa/util/version.py.in
26         sed -e "s,@VERSIONTAG@,$(VERSIONTAG),g" -e "s,@SCMURL@,$(SCMURL),g" sfa/util/version.py.in > $@
27
28 xmlbuilder-install:
29         cd xmlbuilder-0.9 && python setup.py install --root=$(DESTDIR) && cd -
30  
31 python-install:
32         python setup.py install --root=$(DESTDIR)       
33         chmod 444 $(DESTDIR)/etc/sfa/default_config.xml
34
35 python-clean: version-clean
36         python setup.py clean
37 #       rm $(init)
38
39 version-clean:
40         rm -f sfa/util/version.py
41
42 .PHONY: python version python-install python-clean version-clean xmlbuilder-install 
43 ##########
44 wsdl: 
45         $(MAKE) -C wsdl 
46
47 # propagate DESTDIR from the specfile
48 wsdl-install:
49         $(MAKE) -C wsdl install 
50
51 wsdl-clean:
52         $(MAKE) -C wsdl clean
53
54 .PHONY: wsdl wsdl-install wsdl-clean
55
56 ##########
57 tests-install:
58         mkdir -p $(DESTDIR)/usr/share/sfa/tests
59         install -m 755 tests/*.py $(DESTDIR)/usr/share/sfa/tests/
60
61 tests-uninstall:
62         rm -rf $(DESTDIR)/usr/share/sfa/tests
63
64 .PHONY: tests-install tests-uninstall
65
66 ########## refreshing methods package metafile
67 # Metafiles - manage Legacy/ and Accessors by hand
68 init := sfa/methods/__init__.py 
69
70 index: $(init)
71
72 index-clean:
73         rm $(init)
74
75 methods_now := $(sort $(shell fgrep -v '"' sfa/methods/__init__.py 2>/dev/null))
76 # what should be declared
77 methods_paths := $(filter-out %/__init__.py, $(wildcard sfa/methods/*.py))
78 methods_files := $(sort $(notdir $(methods_paths:.py=)))
79
80 ifneq ($(methods_now),$(methods_files))
81 sfa/methods/__init__.py: force
82 endif
83 sfa/methods/__init__.py: 
84         (echo '## Please use make index to update this file' ; echo 'all = """' ; cd sfa/methods; ls -1 *.py | grep -v __init__ | sed -e 's,.py$$,,' ; echo '""".split()') > $@
85
86 force:
87
88 ##########
89 tags:   
90         find . -type f | egrep -v '/\.git/|/\.svn/|TAGS|\.py[co]$$|\.doc$$|\.html$$|\.pdf$$|~$$|\.png$$|\.svg$$|\.out$$|\.bak$$|\.xml$$' | xargs etags
91 .PHONY: tags
92
93 signatures:
94         (cd sfa/methods; grep 'def.*call' *.py > SIGNATURES)
95 .PHONY: signatures
96
97 ########## sync
98 # 2 forms are supported
99 # (*) if your plc root context has direct ssh access:
100 # make sync PLC=private.one-lab.org
101 # (*) otherwise, entering through the root context
102 # make sync PLCHOST=testbox1.inria.fr GUEST=vplc03.inria.fr
103
104 PLCHOST ?= testplc.onelab.eu
105
106 ifdef GUEST
107 ifdef PLCHOST
108 SSHURL:=root@$(PLCHOST):/vservers/$(GUEST)
109 SSHCOMMAND:=ssh root@$(PLCHOST) vserver $(GUEST)
110 endif
111 endif
112 ifdef PLC
113 SSHURL:=root@$(PLC):/
114 SSHCOMMAND:=ssh root@$(PLC)
115 endif
116
117 LOCAL_RSYNC_EXCLUDES    += --exclude '*.pyc' 
118 LOCAL_RSYNC_EXCLUDES    += --exclude '*.png' --exclude '*.svg' --exclude '*.out'
119 RSYNC_EXCLUDES          := --exclude .svn --exclude .git --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
120 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
121 RSYNC                   := rsync -a -v $(RSYNC_COND_DRY_RUN) --no-owner $(RSYNC_EXCLUDES)
122
123 CLIENTS = sfi.py getNodes.py getRecord.py setRecord.py \
124 sfiAddAttribute.py sfiAddSliver.py sfiDeleteAttribute.py sfiDeleteSliver.py sfiListNodes.py \
125 sfiListSlivers.py sfadump.py
126
127 BINS =  ./config/sfa-config-tty ./config/gen-sfa-cm-config.py \
128         ./sfa/plc/sfa-import-plc.py ./sfa/plc/sfa-nuke-plc.py ./sfa/server/sfa-server.py \
129         $(foreach client,$(CLIENTS),./sfa/client/$(client))
130
131 sync:
132 ifeq (,$(SSHURL))
133         @echo "sync: You must define, either PLC, or PLCHOST & GUEST, on the command line"
134         @echo "  e.g. make sync PLC=private.one-lab.org"
135         @echo "  or   make sync PLCHOST=testbox1.inria.fr GUEST=vplc03.inria.fr"
136         @exit 1
137 else
138         +$(RSYNC) ./sfa/ $(SSHURL)/usr/lib\*/python2.\*/site-packages/sfa/
139         +$(RSYNC) ./tests/ $(SSHURL)/root/tests-sfa
140         +$(RSYNC)  $(BINS) $(SSHURL)/usr/bin
141         $(SSHCOMMAND) exec service sfa restart
142 endif
143
144 .PHONY: sync
145 ##########