wrong help message
[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 #
9
10 # Metafiles
11 init := PLC/__init__.py PLC/Methods/__init__.py PLC/Legacy/__init__.py
12
13 # python-pycurl and python-psycopg2 avail. from fedora 5
14 # we used to ship our own version of psycopg2 and pycurl, for fedora4
15 # starting with 5.0, support for these two modules is taken out
16
17 # Other stuff - doc not implicit, it's redone by myplc-docs
18 subdirs := php php/xmlrpc
19
20 # autoconf compatible variables
21 DESTDIR := /
22 datadir := /usr/share
23 bindir := /usr/bin
24
25 PWD := $(shell pwd)
26
27 all: $(init) $(subdirs) 
28         python setup.py build
29
30 install: 
31         python setup.py install \
32             --install-purelib=$(DESTDIR)/$(datadir)/plc_api \
33             --install-scripts=$(DESTDIR)/$(datadir)/plc_api \
34             --install-data=$(DESTDIR)/$(datadir)/plc_api
35         install -D -m 755 php/xmlrpc/xmlrpc.so $(DESTDIR)/$(shell php-config --extension-dir)/xmlrpc.so
36
37 $(subdirs): $(init)
38
39 $(subdirs): %:
40         $(MAKE) -C $@
41
42 clean: 
43         find . -name '*.pyc' | xargs rm -f
44         rm -f $(INIT)
45         for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir clean ; done
46         python setup.py clean && rm -rf build
47
48 index: $(init)
49
50 index-clean:
51         rm $(init)
52
53 #################### regenerate indexes - not used by the build, as both files are svn added - please update as appropriate
54
55 ########## PLC/
56 # the current content of __init__.py
57 PLC_now := $(sort $(shell fgrep -v '"' PLC/__init__.py 2>/dev/null))
58 # what should be declared
59 PLC_paths := $(filter-out %/__init__.py, $(wildcard PLC/*.py))
60 PLC_files := $(sort $(notdir $(PLC_paths:.py=)))
61
62 ifneq ($(PLC_now),$(PLC_files))
63 PLC/__init__.py: force
64 endif
65 PLC/__init__.py: 
66         (echo 'all = """' ; cd PLC; ls -1 *.py | grep -v __init__ | sed -e 's,.py$$,,' ; echo '""".split()') > $@
67
68 ########## Methods/
69 # the current content of __init__.py
70 METHODS_now := $(sort $(shell fgrep -v '"' PLC/Methods/__init__.py 2>/dev/null))
71 # what should be declared
72 METHODS_paths := $(filter-out %/__init__.py, $(wildcard PLC/Methods/*.py PLC/Methods/system/*.py))
73 METHODS_files := $(sort $(notdir $(subst system/, system., $(METHODS_paths:.py=))))
74
75 ifneq ($(METHODS_now),$(METHODS_files))
76 PLC/Methods/__init__.py: force
77 endif
78 PLC/Methods/__init__.py: 
79         (echo 'methods = """' ; cd PLC/Methods; ls -1 *.py system/*.py | grep -v __init__ | sed -e 's,.py$$,,' -e 's,system/,system.,' ; echo '""".split()') > $@
80
81 ########## Legacy/
82 # the current content of __init__.py
83 LEGACY_now := $(sort $(shell fgrep -v '"' PLC/Legacy/__init__.py 2>/dev/null))
84 # what should be declared
85 LEGACY_paths := $(filter-out %/__init__.py, $(wildcard PLC/Legacy/*.py))
86 LEGACY_files := $(sort $(notdir $(LEGACY_paths:.py=)))
87
88 ifneq ($(LEGACY_now),$(LEGACY_files))
89 PLC/Legacy/__init__.py: force
90 endif
91 PLC/Legacy/__init__.py: 
92         (echo '# each module to define in "methods" the set of methods that it defines' ;\
93          echo '__all__ = """' ; \
94          cd PLC/Legacy; ls -1 *.py | grep -v __init__ | sed -e 's,.py$$,,' ; \
95          echo '""".split()') > $@
96
97 ##########
98 force:
99
100 .PHONY: all install force clean index tags $(subdirs)
101
102 #################### devel tools
103 tags:
104         find . '(' -name '*.py' -o -name '*.sql' -o -name '*.php' -o -name Makefile ')' | xargs etags
105
106 .PHONY: tags
107
108 ########## sync
109 # 2 forms are supported
110 # (*) if your plc root context has direct ssh access:
111 # make sync PLC=private.one-lab.org
112 # (*) otherwise, entering through the root context
113 # make sync PLCHOST=testbox1.inria.fr GUEST=vplc03.inria.fr
114
115 ifdef GUEST
116 ifdef PLCHOST
117 SSHURL:=root@$(PLCHOST):/vservers/$(GUEST)
118 SSHCOMMAND:=ssh root@$(PLCHOST) vserver $(GUEST)
119 endif
120 endif
121 ifdef PLC
122 SSHURL:=root@$(PLC):/
123 SSHCOMMAND:=ssh root@$(PLC)
124 endif
125
126 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' 
127 RSYNC_EXCLUDES          := --exclude .svn --exclude CVS --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
128 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
129 RSYNC                   := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
130
131 sync:
132 ifeq (,$(SSHURL))
133         @echo "sync: You must define, either PLC, or PLCHOST & GUEST, on the command line"
134         @echo "  e.g. make sync PLC=private.one-lab.org"
135         @echo "  or   make sync PLCHOST=testbox1.inria.fr GUEST=vplc03.inria.fr"
136         @exit 1
137 else
138         +$(RSYNC) PLC planetlab5.sql migrations $(SSHURL)/usr/share/plc_api/
139         $(SSHCOMMAND) exec apachectl graceful
140 endif
141
142 #################### convenience, for debugging only
143 # make +foo : prints the value of $(foo)
144 # make ++foo : idem but verbose, i.e. foo=$(foo)
145 ++%: varname=$(subst +,,$@)
146 ++%:
147         @echo "$(varname)=$($(varname))"
148 +%: varname=$(subst +,,$@)
149 +%:
150         @echo "$($(varname))"
151