oops
[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 PLCHOST ?= testplc.onelab.eu
65
66 ifdef PLC
67 SSHURL:=root@$(PLC):/
68 SSHCOMMAND:=ssh root@$(PLC)
69 else
70 ifdef PLCHOSTLXC
71 SSHURL:=root@$(PLCHOST):/var/lib/lxc/$(GUESTNAME)/rootfs
72 SSHCOMMAND:=ssh root@$(PLCHOSTLXC) ssh $(GUESTHOSTNAME)
73 else
74 ifdef PLCHOSTVS
75 SSHURL:=root@$(PLCHOSTVS):/vservers/$(GUESTNAME)
76 SSHCOMMAND:=ssh root@$(PLCHOSTVS) vserver $(GUESTNAME) exec
77 endif
78 endif
79 endif
80
81 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' --exclude Accessors_site.py
82 RSYNC_EXCLUDES          := --exclude .svn --exclude .git --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
83 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
84 RSYNC                   := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
85
86 sync:
87 ifeq (,$(SSHURL))
88         @echo "sync: I need more info from the command line, e.g."
89         @echo "  make sync PLC=boot.planetlab.eu"
90         @echo "  make sync PLCHOSTVS=.. GUESTNAME=.."
91         @echo "  make sync PLCHOSTLXC=.. GUESTNAME=.. GUESTHOSTNAME=.."
92         @exit 1
93 else
94         +$(RSYNC) plcsh PLC planetlab5.sql migrations aspects $(SSHURL)/usr/share/plc_api/
95         +$(RSYNC) db-config.d/ $(SSHURL)/etc/planetlab/db-config.d/
96         +$(RSYNC) plc.d/ $(SSHURL)/etc/plc.d/
97         $(SSHCOMMAND) apachectl graceful
98 endif
99
100 #################### convenience, for debugging only
101 # make +foo : prints the value of $(foo)
102 # make ++foo : idem but verbose, i.e. foo=$(foo)
103 ++%: varname=$(subst +,,$@)
104 ++%:
105         @echo "$(varname)=$($(varname))"
106 +%: varname=$(subst +,,$@)
107 +%:
108         @echo "$($(varname))"
109