disable pycurl build for fc2 (not supported anyway)
[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: Makefile,v 1.10 2006/12/15 16:20:20 mlhuang Exp $
8 #
9
10 # Metafiles
11 init := PLC/__init__.py PLC/Methods/__init__.py
12
13 # Python modules
14 modules := psycopg2
15
16 # Temporarily until we can kill the Fedora Core 2 build
17 curl_vernum := $(shell printf %d 0x$(shell curl-config --vernum))
18 pycurl_vernum := $(shell printf %d 0x070d01) # 7.13.1
19 ifeq ($(shell test $(curl_vernum) -ge $(pycurl_vernum) && echo 1),1)
20 modules += pycurl
21 endif
22
23 modules-install := $(foreach module, $(modules), $(module)-install)
24 modules-clean := $(foreach module, $(modules), $(module)-clean)
25
26 # Other stuff
27 subdirs := doc php php/xmlrpc
28
29 # autoconf compatible variables
30 DESTDIR := /plc/root
31 datadir := /usr/share
32 bindir := /usr/bin
33
34 PWD := $(shell pwd)
35
36 all: $(init) $(subdirs) $(modules)
37         python setup.py build
38
39 install: $(modules-install)
40         python setup.py install \
41             --install-purelib=$(DESTDIR)/$(datadir)/plc_api \
42             --install-scripts=$(DESTDIR)/$(datadir)/plc_api \
43             --install-data=$(DESTDIR)/$(datadir)/plc_api
44         install -D -m 755 php/xmlrpc/xmlrpc.so $(DESTDIR)/$(shell php-config --extension-dir)/xmlrpc.so
45
46 $(subdirs): $(init) $(modules)
47
48 $(subdirs): %:
49         $(MAKE) -C $@
50
51 $(modules):
52         # Install in the current directory so that we can import it while developing
53         cd $@ && \
54             python setup.py build && \
55             python setup.py install_lib --install-dir=$(PWD)
56
57 $(modules-install): %-install:
58         cd $* && \
59             python setup.py install_lib --install-dir=$(DESTDIR)/$(datadir)/plc_api
60
61 $(modules-clean): %-clean:
62         cd $* && python setup.py clean && rm -rf build
63
64 clean: $(modules-clean)
65         find . -name '*.pyc' | xargs rm -f
66         rm -f $(INIT)
67         for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir clean ; done
68         python setup.py clean && rm -rf build
69
70 index: $(init)
71
72 tags:
73         find . '(' -name '*.py' -o -name '*.sql' -o -name '*.php' -o -name Makefile ')' | xargs etags
74
75 # All .py files in PLC/
76 PLC := $(filter-out %/__init__.py, $(wildcard PLC/*.py))
77 PLC_init := all = '$(notdir $(PLC:.py=))'.split()
78
79 PLC/__init__.py:
80         echo "$(PLC_init)" >$@
81
82 ifneq ($(sort $(PLC_init)), $(sort $(shell cat PLC/__init__.py 2>/dev/null)))
83 PLC/__init__.py: force
84 endif
85
86 # All .py files in PLC/Methods/ and PLC/Methods/system/
87 METHODS := $(filter-out %/__init__.py, $(wildcard PLC/Methods/*.py PLC/Methods/system/*.py))
88 Methods_init := methods = '$(notdir $(subst system/, system., $(METHODS:.py=)))'.split()
89
90 PLC/Methods/__init__.py:
91         echo "$(Methods_init)" >$@
92
93 ifneq ($(sort $(Methods_init)), $(sort $(shell cat PLC/Methods/__init__.py 2>/dev/null)))
94 PLC/Methods/__init__.py: force
95 endif
96
97 force:
98
99 .PHONY: all install force clean index tags $(subdirs) $(modules)