Merge commit 'origin/master'
[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 subdirs := php/xmlrpc
14
15 # autoconf compatible variables
16 DESTDIR := /
17 datadir := /usr/share
18 bindir := /usr/bin
19
20 PWD := $(shell pwd)
21
22 all: $(subdirs) 
23         python setup.py build
24
25 install: 
26         python setup.py install \
27             --install-purelib=$(DESTDIR)/$(datadir)/plc_api \
28             --install-scripts=$(DESTDIR)/$(datadir)/plc_api \
29             --install-data=$(DESTDIR)/$(datadir)/plc_api
30         install -D -m 755 php/xmlrpc/xmlrpc.so $(DESTDIR)/$(shell php-config --extension-dir)/xmlrpc.so
31
32 $(subdirs): %:
33         $(MAKE) -C $@
34
35 clean: 
36         find . -name '*.pyc' | xargs rm -f
37         rm -f $(INIT)
38         for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir clean ; done
39         python setup.py clean && rm -rf build
40
41 index:
42         echo "This step is obsolete"
43
44 ##########
45
46 force:
47
48 .PHONY: all install force clean index tags $(subdirs)
49
50 #################### devel tools
51 tags:
52         find . '(' -name '*.py' -o -name '*.sql' -o -name '*.php' -o -name Makefile ')' | xargs etags
53
54 .PHONY: tags
55
56 ########## sync
57 # 2 forms are supported
58 # (*) if your plc root context has direct ssh access:
59 # make sync PLC=private.one-lab.org
60 # (*) otherwise, entering through the root context
61 # make sync PLCHOST=testplc.onelab.eu GUEST=vplc03.inria.fr
62
63 PLCHOST ?= testplc.onelab.eu
64
65 ifdef GUEST
66 SSHURL:=root@$(PLCHOST):/vservers/$(GUEST)
67 SSHCOMMAND:=ssh root@$(PLCHOST) vserver $(GUEST)
68 endif
69 ifdef PLC
70 SSHURL:=root@$(PLC):/
71 SSHCOMMAND:=ssh root@$(PLC)
72 endif
73
74 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' 
75 RSYNC_EXCLUDES          := --exclude .svn --exclude CVS --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
76 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
77 RSYNC                   := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
78
79 sync:
80 ifeq (,$(SSHURL))
81         @echo "sync: You must define, either PLC, or PLCHOST & GUEST, on the command line"
82         @echo "  e.g. make sync PLC=boot.planetlab.eu"
83         @echo "  or   make sync PLCHOST=testplc.onelab.eu GUEST=vplc03.inria.fr"
84         @exit 1
85 else
86         +$(RSYNC) plcsh PLC planetlab5.sql migrations $(SSHURL)/usr/share/plc_api/
87         +$(RSYNC) db-config.d/ $(SSHURL)/etc/planetlab/db-config.d/
88         +$(RSYNC) plc.d/ $(SSHURL)/etc/plc.d/
89         $(SSHCOMMAND) exec apachectl graceful
90 endif
91
92 #################### convenience, for debugging only
93 # make +foo : prints the value of $(foo)
94 # make ++foo : idem but verbose, i.e. foo=$(foo)
95 ++%: varname=$(subst +,,$@)
96 ++%:
97         @echo "$(varname)=$($(varname))"
98 +%: varname=$(subst +,,$@)
99 +%:
100         @echo "$($(varname))"
101