Setting tag plcapi-5.4-2
[plcapi.git] / Makefile
1 #
2 # (Re)builds Python metafiles (__init__.py) and documentation
3 #
4 # Mark Huang <mlhuang@cs.princeton.edu>
5 # Copyright (C) 2005 The Trustees of Princeton University
6 #
7
8 # python-pycurl and python-psycopg2 avail. from fedora 5
9 # we used to ship our own version of psycopg2 and pycurl, for fedora4
10 # starting with 5.0, support for these two modules is taken out
11
12 # Other stuff - doc not implicit, it's redone by myplc-docs
13
14 # autoconf compatible variables
15 DESTDIR := /
16 datadir := /usr/share
17 bindir := /usr/bin
18
19 PWD := $(shell pwd)
20
21 all: 
22         python setup.py build
23
24 install: install-python install-phpxmlrpc
25
26 install-python:
27         python setup.py install \
28             --install-purelib=$(DESTDIR)/$(datadir)/plc_api \
29             --install-scripts=$(DESTDIR)/$(datadir)/plc_api \
30             --install-data=$(DESTDIR)/$(datadir)/plc_api
31
32 # phpxmlrpc is a git subtree; we just ship all its contents
33 # under /usr/share/plc_api/php/phpxmlrpc
34 install-phpxmlrpc:
35         mkdir -p $(DESTDIR)/$(datadir)/plc_api/php/phpxmlrpc/
36         rsync --exclude .git -ai php/phpxmlrpc/ $(DESTDIR)/$(datadir)/plc_api/php/phpxmlrpc/
37
38 clean: 
39         find . -name '*.pyc' | xargs rm -f
40         python setup.py clean && rm -rf build
41
42 index:
43         echo "This step is obsolete"
44
45 ##########
46
47 force:
48
49 .PHONY: all install force clean index tags
50
51 #################### devel tools
52 tags:
53         find . '(' -name '*.py' -o -name '*.sql' -o -name '*.php' -o -name Makefile -o -name '[0-9][0-9][0-9]*' ')' | fgrep -v '.git/' | xargs etags
54
55 .PHONY: tags
56
57 ########## sync
58 # 2 forms are supported
59 # (*) if your plc root context has direct ssh access:
60 # make sync PLC=private.one-lab.org
61 # (*) otherwise, for test deployments, use on your testmaster
62 # $ run export
63 # and cut'n paste the export lines before you run make sync
64
65 ifdef PLC
66 SSHURL:=root@$(PLC):/
67 SSHCOMMAND:=ssh root@$(PLC)
68 else
69 ifdef PLCHOSTLXC
70 SSHURL:=root@$(PLCHOSTLXC):/vservers/$(GUESTNAME)
71 SSHCOMMAND:=ssh root@$(PLCHOSTLXC) ssh -o StrictHostKeyChecking=no -o LogLevel=quiet $(GUESTHOSTNAME)
72 endif
73 endif
74
75 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' --exclude Accessors_site.py
76 RSYNC_EXCLUDES          := --exclude .svn --exclude .git --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
77 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
78 RSYNC                   := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
79
80 sync:
81 ifeq (,$(SSHURL))
82         @echo "sync: I need more info from the command line, e.g."
83         @echo "  make sync PLC=boot.planetlab.eu"
84         @echo "  make sync PLCHOSTLXC=.. GUESTHOSTNAME=.. GUESTNAME=.."
85         @exit 1
86 else
87         +$(RSYNC) plcsh PLC planetlab5.sql migrations $(SSHURL)/usr/share/plc_api/
88         +$(RSYNC) db-config.d/ $(SSHURL)/etc/planetlab/db-config.d/
89         +$(RSYNC) plc.d/ $(SSHURL)/etc/plc.d/
90         +$(RSYNC) apache/plc.wsgi $(SSHURL)/usr/share/plc_api/apache/
91         $(SSHCOMMAND) /etc/plc.d/httpd stop
92         $(SSHCOMMAND) /etc/plc.d/httpd start
93 endif
94
95 #################### convenience, for debugging only
96 # make +foo : prints the value of $(foo)
97 # make ++foo : idem but verbose, i.e. foo=$(foo)
98 ++%: varname=$(subst +,,$@)
99 ++%:
100         @echo "$(varname)=$($(varname))"
101 +%: varname=$(subst +,,$@)
102 +%:
103         @echo "$($(varname))"
104