b9db3811425cfcd0832e1b0d06aff72c1412fade
[zope-bootstrap.git] / Makefile.pybase
1 # -*- makefile -*-
2
3 PYTHON_VERSION  ?= 2.4.6
4 PYTHON_URL      ?= http://www.python.org/ftp/python/$(PYTHON_VERSION)/Python-$(PYTHON_VERSION).tgz
5 SETUPTOOLS_URL  ?= http://peak.telecommunity.com/dist/ez_setup.py
6
7 ###########################################################################
8
9 PYTHON_DIR ?= python
10
11 PYTHON       = $(BASEDIR)/$(PYTHON_DIR)/bin/python
12 EASY_INSTALL = $(BASEDIR)/$(PYTHON_DIR)/bin/easy_install
13 PIP          = $(BASEDIR)/$(PYTHON_DIR)/bin/pip
14 PASTER       = $(BASEDIR)/$(PYTHON_DIR)/bin/paster
15
16 ###########################################################################
17
18 python-unpack: $(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README
19 $(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README:
20         mkdir -p $(PYTHON_DIR)
21         @$(httpget) $(PYTHON_URL) $(PYTHON_DIR)/python.tgz
22         tar -C $(PYTHON_DIR) -xzf $(PYTHON_DIR)/python.tgz
23         rm -f $(PYTHON_DIR)/python.tgz
24 .PHONY: python-unpack
25
26 python-build: $(PYTHON)
27 $(PYTHON):
28         cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && ./configure --prefix=$(BASEDIR)/$(PYTHON_DIR)
29         cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make
30         cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make install
31 .PHONY: python-build
32
33 python-rebuild: python-clean python-build
34 .PHONY: python-rebuild
35
36 python-clean:
37         cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make clean
38         rm -f $(PYTHON)
39 .PHONY: python-clean
40
41 python: python-unpack python-build
42 .PHONY: python
43
44 setuptools: $(BASEDIR)/$(PYTHON_DIR)/bin/easy_install
45 $(BASEDIR)/$(PYTHON_DIR)/bin/easy_install:
46         mkdir -p $(PYTHON_DIR)/Extensions
47         @$(httpget) $(SETUPTOOLS_URL) $(PYTHON_DIR)/Extensions/ez_setup.py
48         @(                                                                                                              \
49             if [ -r $(DLCACHE)/setuptools-*.egg ]; then                                                                 \
50                 name="`cd $(DLCACHE); echo setuptools-*.egg`";                                                          \
51                 echo "Fetching '$$name' from cache.";                                                                   \
52                 cp "$(DLCACHE)/$$name" $(PYTHON_DIR)/Extensions;                                                        \
53             else                                                                                                        \
54                 echo "Downloading setuptools.";                                                                         \
55                 ( cd $(PYTHON_DIR)/Extensions && $(PYTHON) -c 'import ez_setup; ez_setup.download_setuptools()' );      \
56                 cp $(PYTHON_DIR)/Extensions/setuptools-*.egg $(DLCACHE);                                                \
57             fi;                                                                                                         \
58         )
59         cd $(PYTHON_DIR)/Extensions && $(PYTHON) ez_setup.py
60 .PHONY: setuptools
61
62 pip: $(PIP)
63 $(PIP):
64         @$(dlegg) pip
65         $(EASY_INSTALL) $(DLCACHE)/pip-*.egg
66
67 pybase: python setuptools pip
68 .PHONY: pybase
69
70 ###########################################################################
71
72 debdepends::
73         aptitude install build-essential zlibc
74
75 eggs::
76         @$(install) zc.buildout
77
78 .gitignore::
79         @$(gitignore) /python/
80
81 .env::
82         @$(env) PATH $(BASEDIR)/$(PYTHON_DIR)/bin
83
84 clean:: python-clean
85
86 setup:: pybase