2 # (Re)builds Python metafiles (__init__.py) and documentation
4 # Mark Huang <mlhuang@cs.princeton.edu>
5 # Copyright (C) 2005 The Trustees of Princeton University
11 init := PLC/__init__.py PLC/Methods/__init__.py
14 # see PLCAPI.spec for the settings of modules
15 # default is : no extra module get built
17 ## Temporarily until we can kill the Fedora Core 2 build
18 #curl_vernum := $(shell printf %d 0x$(shell curl-config --vernum))
19 #pycurl_vernum := $(shell printf %d 0x070d01) # 7.13.1
20 #pycurl_incompatnum := $(shell printf %d 0x071000) # 7.16.0
21 #ifeq ($(shell test $(curl_vernum) -ge $(pycurl_vernum) && echo 1),1)
22 #ifeq ($(shell test $(curl_vernum) -ge $(pycurl_incompatnum) && echo 0),1)
27 modules-install := $(foreach module, $(modules), $(module)-install)
28 modules-clean := $(foreach module, $(modules), $(module)-clean)
31 subdirs := doc php php/xmlrpc
33 # autoconf compatible variables
40 all: $(init) $(subdirs) $(modules)
43 install: $(modules-install)
44 python setup.py install \
45 --install-purelib=$(DESTDIR)/$(datadir)/plc_api \
46 --install-scripts=$(DESTDIR)/$(datadir)/plc_api \
47 --install-data=$(DESTDIR)/$(datadir)/plc_api
48 install -D -m 755 php/xmlrpc/xmlrpc.so $(DESTDIR)/$(shell php-config --extension-dir)/xmlrpc.so
49 install -D -m 755 refresh-peer.py $(DESTDIR)/$(bindir)/refresh-peer.py
51 $(subdirs): $(init) $(modules)
57 # Install in the current directory so that we can import it while developing
59 python setup.py build && \
60 python setup.py install_lib --install-dir=$(PWD)
62 $(modules-install): %-install:
64 python setup.py install_lib --install-dir=$(DESTDIR)/$(datadir)/plc_api
66 $(modules-clean): %-clean:
67 cd $* && python setup.py clean && rm -rf build
69 clean: $(modules-clean)
70 find . -name '*.pyc' | xargs rm -f
72 for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir clean ; done
73 python setup.py clean && rm -rf build
81 find . '(' -name '*.py' -o -name '*.sql' -o -name '*.php' -o -name Makefile ')' | xargs etags
83 ########## make sync PLCHOST=hostname
85 PLCSSH:=root@$(PLCHOST)
88 LOCAL_RSYNC_EXCLUDES := --exclude '*.pyc'
89 RSYNC_EXCLUDES := --exclude .svn --exclude CVS --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
90 RSYNC_COND_DRY_RUN := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
91 RSYNC := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
95 echo "sync: You must define target host as PLCHOST on the command line"
96 echo " e.g. make sync PLCHOST=private.one-lab.org" ; exit 1
98 +$(RSYNC) PLC planetlab4.sql migrations $(PLCSSH):/plc/root/usr/share/plc_api/
99 ssh $(PLCSSH) chroot /plc/root apachectl graceful
103 # All .py files in PLC/
105 # the current content of __init__.py
106 PLC_now := $(sort $(shell fgrep -v '"' PLC/__init__.py 2>/dev/null))
107 # what should be declared
108 PLC_paths := $(filter-out %/__init__.py, $(wildcard PLC/*.py))
109 PLC_files := $(sort $(notdir $(PLC_paths:.py=)))
111 ifneq ($(PLC_now),$(PLC_files))
112 PLC/__init__.py: force
115 (echo 'all = """' ; cd PLC; ls -1 *.py | grep -v __init__ | sed -e 's,.py$$,,' ; echo '""".split()') > $@
118 # the current content of __init__.py
119 METHODS_now := $(sort $(shell fgrep -v '"' PLC/Methods/__init__.py 2>/dev/null))
120 # what should be declared
121 METHODS_paths := $(filter-out %/__init__.py, $(wildcard PLC/Methods/*.py PLC/Methods/system/*.py))
122 METHODS_files := $(sort $(notdir $(subst system/, system., $(METHODS_paths:.py=))))
124 ifneq ($(METHODS_now),$(METHODS_files))
125 PLC/Methods/__init__.py: force
127 PLC/Methods/__init__.py:
128 (echo 'methods = """' ; cd PLC/Methods; ls -1 *.py system/*.py | grep -v __init__ | sed -e 's,.py$$,,' -e 's,system/,system.,' ; echo '""".split()') > $@
132 .PHONY: all install force clean index tags $(subdirs) $(modules)
134 #################### convenience, for debugging only
135 # make +foo : prints the value of $(foo)
136 # make ++foo : idem but verbose, i.e. foo=$(foo)
137 ++%: varname=$(subst +,,$@)
139 @echo "$(varname)=$($(varname))"
140 +%: varname=$(subst +,,$@)
142 @echo "$($(varname))"