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