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