Fix version output when missing.
[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 # $Id$
8 # $URL$
9 #
10
11 # python-pycurl and python-psycopg2 avail. from fedora 5
12 # we used to ship our own version of psycopg2 and pycurl, for fedora4
13 # starting with 5.0, support for these two modules is taken out
14
15 # Other stuff - doc not implicit, it's redone by myplc-docs
16 subdirs := php php/xmlrpc
17
18 # autoconf compatible variables
19 DESTDIR := /
20 datadir := /usr/share
21 bindir := /usr/bin
22
23 PWD := $(shell pwd)
24
25 all: $(subdirs) 
26         python setup.py build
27
28 install: 
29         python setup.py install \
30             --install-purelib=$(DESTDIR)/$(datadir)/plc_api \
31             --install-scripts=$(DESTDIR)/$(datadir)/plc_api \
32             --install-data=$(DESTDIR)/$(datadir)/plc_api
33         install -D -m 755 php/xmlrpc/xmlrpc.so $(DESTDIR)/$(shell php-config --extension-dir)/xmlrpc.so
34
35 $(subdirs): %:
36         $(MAKE) -C $@
37
38 clean: 
39         find . -name '*.pyc' | xargs rm -f
40         rm -f $(INIT)
41         for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir clean ; done
42         python setup.py clean && rm -rf build
43
44 index:
45         echo "This step is obsolete"
46
47 ##########
48
49 force:
50
51 .PHONY: all install force clean index tags $(subdirs)
52
53 #################### devel tools
54 tags:
55         find . '(' -name '*.py' -o -name '*.sql' -o -name '*.php' -o -name Makefile ')' | xargs etags
56
57 .PHONY: tags
58
59 ########## sync
60 # 2 forms are supported
61 # (*) if your plc root context has direct ssh access:
62 # make sync PLC=private.one-lab.org
63 # (*) otherwise, entering through the root context
64 # make sync PLCHOST=testplc.onelab.eu GUEST=vplc03.inria.fr
65
66 PLCHOST ?= testplc.onelab.eu
67
68 ifdef GUEST
69 SSHURL:=root@$(PLCHOST):/vservers/$(GUEST)
70 SSHCOMMAND:=ssh root@$(PLCHOST) vserver $(GUEST)
71 endif
72 ifdef PLC
73 SSHURL:=root@$(PLC):/
74 SSHCOMMAND:=ssh root@$(PLC)
75 endif
76
77 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' 
78 RSYNC_EXCLUDES          := --exclude .svn --exclude CVS --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
79 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
80 RSYNC                   := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
81
82 sync:
83 ifeq (,$(SSHURL))
84         @echo "sync: You must define, either PLC, or PLCHOST & GUEST, on the command line"
85         @echo "  e.g. make sync PLC=boot.planetlab.eu"
86         @echo "  or   make sync PLCHOST=testplc.onelab.eu GUEST=vplc03.inria.fr"
87         @exit 1
88 else
89         +$(RSYNC) plcsh PLC planetlab5.sql migrations $(SSHURL)/usr/share/plc_api/
90         +$(RSYNC) db-config.d/ $(SSHURL)/etc/planetlab/db-config.d/
91         +$(RSYNC) plc.d/ $(SSHURL)/etc/plc.d/
92         $(SSHCOMMAND) exec apachectl graceful
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