first draft for ilinks : typed and valued links between interfaces
[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
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         install -D -m 755 refresh-peer.py $(DESTDIR)/$(bindir)/refresh-peer.py
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 # All .py files in PLC/
56
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 'all = """' ; cd PLC; ls -1 *.py | grep -v __init__ | sed -e 's,.py$$,,' ; echo '""".split()') > $@
68
69
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 'methods = """' ; cd PLC/Methods; ls -1 *.py system/*.py | grep -v __init__ | sed -e 's,.py$$,,' -e 's,system/,system.,' ; echo '""".split()') > $@
81
82 force:
83
84 .PHONY: all install force clean index tags $(subdirs)
85
86 #################### devel tools
87 tags:
88         find . '(' -name '*.py' -o -name '*.sql' -o -name '*.php' -o -name Makefile ')' | xargs etags
89
90 ########## make sync PLCHOST=hostname
91 ifdef PLCHOST
92 ifdef VSERVER
93 PLCSSH:=root@$(PLCHOST):/vservers/$(VSERVER)
94 endif
95 endif
96
97 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' 
98 RSYNC_EXCLUDES          := --exclude .svn --exclude CVS --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
99 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
100 RSYNC                   := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
101
102 sync:
103 ifeq (,$(PLCSSH))
104         echo "sync: You must define PLCHOST and VSERVER on the command line"
105         echo " e.g. make sync PLCHOST=private.one-lab.org VSERVER=myplc01" ; exit 1
106 else
107         +$(RSYNC) PLC planetlab5.sql migrations $(PLCSSH)/usr/share/plc_api/
108         ssh root@$(PLCHOST) vserver $(VSERVER) exec apachectl graceful
109 endif
110
111 #################### convenience, for debugging only
112 # make +foo : prints the value of $(foo)
113 # make ++foo : idem but verbose, i.e. foo=$(foo)
114 ++%: varname=$(subst +,,$@)
115 ++%:
116         @echo "$(varname)=$($(varname))"
117 +%: varname=$(subst +,,$@)
118 +%:
119         @echo "$($(varname))"
120