remove PLC.Debug.log, use PLC.Logger.logger instead
[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 -o -name '[0-9][0-9][0-9]*' ')' | fgrep -v '.git/' | 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, for test deployments, use on your testmaster
61 # $ run export
62 # and cut'n paste the export lines before you run make sync
63
64 ifdef PLC
65 SSHURL:=root@$(PLC):/
66 SSHCOMMAND:=ssh root@$(PLC)
67 else
68 ifdef PLCHOSTLXC
69 SSHURL:=root@$(PLCHOSTLXC):/vservers/$(GUESTNAME)
70 SSHCOMMAND:=ssh root@$(PLCHOSTLXC) ssh -o StrictHostKeyChecking=no -o LogLevel=quiet $(GUESTHOSTNAME)
71 endif
72 endif
73
74 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' --exclude Accessors_site.py
75 RSYNC_EXCLUDES          := --exclude .svn --exclude .git --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: I need more info from the command line, e.g."
82         @echo "  make sync PLC=boot.planetlab.eu"
83         @echo "  make sync PLCHOSTLXC=.. GUESTHOSTNAME=.. GUESTNAME=.."
84         @exit 1
85 else
86         +$(RSYNC) plcsh PLC planetlab5.sql migrations aspects $(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         +$(RSYNC) apache/plc.wsgi $(SSHURL)/usr/share/plc_api/apache/
90         $(SSHCOMMAND) /etc/plc.d/httpd stop
91         $(SSHCOMMAND) /etc/plc.d/httpd start
92 endif
93
94 #################### convenience, for debugging only
95 # make +foo : prints the value of $(foo)
96 # make ++foo : idem but verbose, i.e. foo=$(foo)
97 ++%: varname=$(subst +,,$@)
98 ++%:
99         @echo "$(varname)=$($(varname))"
100 +%: varname=$(subst +,,$@)
101 +%:
102         @echo "$($(varname))"
103