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