tentatively package unittests in rpm sfa-tests, for the nightlies
[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 ##########
19 python: 
20
21 xmlbuilder-install:
22         cd xmlbuilder-0.9 && python setup.py install --root=$(DESTDIR) && cd -
23  
24 python-install:
25         python setup.py install --root=$(DESTDIR)       
26         chmod 444 $(DESTDIR)/etc/sfa/default_config.xml
27
28 python-clean:
29         python setup.py clean
30         rm $(init)
31
32 .PHONY: python python-install python-clean xmlbuilder-install
33 ##########
34 wsdl: 
35         $(MAKE) -C wsdl 
36
37 # propagate DESTDIR from the specfile
38 wsdl-install:
39         $(MAKE) -C wsdl install 
40
41 wsdl-clean:
42         $(MAKE) -C wsdl clean
43
44 .PHONY: wsdl wsdl-install wsdl-clean
45
46
47 ##########
48 tests-install:
49         mkdir -p $(DESTDIR)/usr/share/sfa/tests
50         install -m 755 tests/*.py $(DESTDIR)/usr/share/sfa/tests/
51
52 tests-uninstall:
53         rm -rf $(DESTDIR)/usr/share/sfa/tests
54
55 .PHONY: tests-install tests-uninstall
56
57 ########## refreshing methods package metafile
58 # Metafiles - manage Legacy/ and Accessors by hand
59 init := sfa/methods/__init__.py 
60
61 index: $(init)
62
63 index-clean:
64         rm $(init)
65
66 methods_now := $(sort $(shell fgrep -v '"' sfa/methods/__init__.py 2>/dev/null))
67 # what should be declared
68 methods_paths := $(filter-out %/__init__.py, $(wildcard sfa/methods/*.py))
69 methods_files := $(sort $(notdir $(methods_paths:.py=)))
70
71 ifneq ($(methods_now),$(methods_files))
72 sfa/methods/__init__.py: force
73 endif
74 sfa/methods/__init__.py: 
75         (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()') > $@
76
77 force:
78
79 ##########
80 tags:   
81         find . -type f | egrep -v '/\.git/|/\.svn/|TAGS|\.py[co]$$|\.doc$$|\.html$$|\.pdf$$|~$$' | xargs etags
82 .PHONY: tags
83
84 signatures:
85         (cd sfa/methods; grep 'def.*call' *.py > SIGNATURES)
86 .PHONY: signatures
87
88 ########## sync
89 # 2 forms are supported
90 # (*) if your plc root context has direct ssh access:
91 # make sync PLC=private.one-lab.org
92 # (*) otherwise, entering through the root context
93 # make sync PLCHOST=testbox1.inria.fr GUEST=vplc03.inria.fr
94
95 PLCHOST ?= testplc.onelab.eu
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 .git --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) --no-owner $(RSYNC_EXCLUDES)
112
113 BINS =  ./config/sfa-config-tty ./config/gen-sfa-cm-config.py \
114         ./sfa/plc/sfa-import-plc.py ./sfa/plc/sfa-nuke-plc.py ./sfa/server/sfa-server.py \
115         ./sfa/client/sfi.py ./sfa/client/getNodes.py ./sfa/client/getRecord.py \
116         ./sfa/client/setRecord.py ./sfa/client/sfadump.py
117
118 sync:
119 ifeq (,$(SSHURL))
120         @echo "sync: You must define, either PLC, or PLCHOST & GUEST, on the command line"
121         @echo "  e.g. make sync PLC=private.one-lab.org"
122         @echo "  or   make sync PLCHOST=testbox1.inria.fr GUEST=vplc03.inria.fr"
123         @exit 1
124 else
125         +$(RSYNC) ./sfa/ $(SSHURL)/usr/lib\*/python2.\*/site-packages/sfa/
126         +$(RSYNC) ./tests/ $(SSHURL)/root/tests-sfa
127         +$(RSYNC)  $(BINS) $(SSHURL)/usr/bin
128         $(SSHCOMMAND) exec service sfa restart
129 endif
130
131 .PHONY: sync
132 ##########