Added 'make uninstall' which uninstalls all files installed by python installer....
[sfa.git] / Makefile
1 #
2 ## (Re)builds Python metafile (__init__.py) and documentation
3
4 # overwritten by the specfile
5 DESTDIR="/"
6
7 ifndef PREFIX
8         PREFIX="/usr"
9 endif
10
11 ##########
12 all: keyconvert python wsdl
13
14 install: keyconvert-install python-install wsdl-install xmlbuilder-install 
15
16 clean: keyconvert-clean python-clean wsdl-clean
17
18 uninstall: python-uninstall
19
20 .PHONY: all install clean 
21
22 ##########
23 keyconvert:
24         $(MAKE) -C keyconvert
25
26 keyconvert-install:
27         $(MAKE) -C keyconvert install
28
29 keyconvert-clean:
30         $(MAKE) -C keyconvert clean
31
32 .PHONY: keyconvert keyconvert-install keyconvert-clean 
33
34 ##########
35 python: 
36
37 xmlbuilder-install:
38         cd xmlbuilder-0.9 && python setup.py install --root=$(DESTDIR) && cd -
39  
40 python-install:
41         python setup.py install --root=$(DESTDIR) --home=$(PREFIX) | grep copying >> python_install.log 
42         chmod 444 $(DESTDIR)/etc/sfa/default_config.xml
43
44 python-uninstall:
45         python setup.py uninstall
46         bash uninstall_python.sh
47         $(awk '{print $$4}' python_install.log)
48
49 python-clean:
50         python setup.py clean
51         rm $(init)
52
53 .PHONY: python python-install python-clean xmlbuilder-install
54 ##########
55 wsdl: 
56         $(MAKE) -C wsdl 
57
58 # propagate DESTDIR from the specfile
59 wsdl-install:
60         $(MAKE) -C wsdl install 
61
62 wsdl-clean:
63         $(MAKE) -C wsdl clean
64
65 .PHONY: wsdl wsdl-install wsdl-clean
66 ##########
67
68 # are the .java files used ?
69 tags:   
70         find . -type f | egrep -v '/\.svn/|TAGS|\.py[co]$$|\.doc$$|\.html$$|\.pdf$$' | xargs etags
71 .PHONY: tags
72
73
74 ########## sync
75 # 2 forms are supported
76 # (*) if your plc root context has direct ssh access:
77 # make sync PLC=private.one-lab.org
78 # (*) otherwise, entering through the root context
79 # make sync PLCHOST=testbox1.inria.fr GUEST=vplc03.inria.fr
80
81 ifdef GUEST
82 ifdef PLCHOST
83 SSHURL:=root@$(PLCHOST):/vservers/$(GUEST)
84 SSHCOMMAND:=ssh root@$(PLCHOST) vserver $(GUEST)
85 endif
86 endif
87 ifdef PLC
88 SSHURL:=root@$(PLC):/
89 SSHCOMMAND:=ssh root@$(PLC)
90 endif
91
92 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' 
93 RSYNC_EXCLUDES          := --exclude .svn --exclude CVS --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
94 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
95 RSYNC                   := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
96
97 BINS =  ./config/sfa-config-tty ./config/gen-sfa-cm-config.py \
98         ./sfa/plc/sfa-import-plc.py ./sfa/plc/sfa-nuke-plc.py ./sfa/server/sfa-server.py \
99         ./sfa/client/sfi.py ./sfa/client/getNodes.py ./sfa/client/getRecord.py \
100         ./sfa/client/setRecord.py ./sfa/client/sfadump.py
101
102 sync:
103 ifeq (,$(SSHURL))
104         @echo "sync: You must define, either PLC, or PLCHOST & GUEST, on the command line"
105         @echo "  e.g. make sync PLC=private.one-lab.org"
106         @echo "  or   make sync PLCHOST=testbox1.inria.fr GUEST=vplc03.inria.fr"
107         @exit 1
108 else
109         +$(RSYNC) ./sfa/ $(SSHURL)/usr/lib/python2.5/site-packages/sfa/
110         +$(RSYNC)  $(BINS) $(SSHURL)/usr/bin
111         $(SSHCOMMAND) exec service sfa restart
112 endif
113
114 .PHONY: sync
115 ##########