# -*- makefile -*-
-PYTHON_VERSION ?= 2.4.6
-PYTHON_URL ?= http://www.python.org/ftp/python/$(PYTHON_VERSION)/Python-$(PYTHON_VERSION).tgz
-SETUPTOOLS_URL ?= http://peak.telecommunity.com/dist/ez_setup.py
-PIL_VERSION ?= 1.1.6
-PIL_URL ?= http://effbot.org/downloads/Imaging-$(PIL_VERSION).tar.gz
+#
+# The master makefile sets up the follosing customizable (double-colon) targtets.
+#
+# debdepends::
+# This optional target may be used by the user to install the necessary
+# system requirements via 'aptitude'. Must be called as root
+#
+# setup::
+# Called for basic setup. Executed before installing the basic eggs
+#
+# eggs::
+# Called to install eggs
+#
+# buildout::
+# Called to install the buildout (e.g. call paster create)
+#
+# init-hook::
+# Called after the buildout is installed but BEFORE bootstraping
+#
+# update-hook::
+# Called BEFORE updating the buildout (e.g. before calling bin/buildout)
+#
+# bootstrap::
+# Called to bootstrap the buildout. Here you can add actions to be
+# performed AFTER bootstraping the project whenever a bootstrap is performed
+#
+# update::
+# Called to update the buildout (calls bin/buildout). Here you can add
+# commands to call AFTER bin/buildout returns.
+#
+# .gitignore::
+# Called to populate the .gitignore file. Use '@$(gitignore) <pattern>' to
+# add a pattern
+#
+# .env::
+# Called to add environment variables to be set when executing a shell
+# Use @$(env) <var> <value> to add a variable settings. <var> may be
+# PATH Add <value> to PATH
+# PYTHONPATH Add <value> to PYTHONPATH
+# <other> Set variable to <value>
+#
+# clean::
+# Called to clean up all generated files
+#
###########################################################################
-PYTHON_DIR=python
BASEDIR=$(shell pwd)
-PYTHON = $(BASEDIR)/$(PYTHON_DIR)/bin/python
-EASY_INSTALL = $(BASEDIR)/$(PYTHON_DIR)/bin/easy_install
-PASTER = $(BASEDIR)/$(PYTHON_DIR)/bin/paster
-
default: update-nonet
+.PHONY: default
-debdepends:
- aptitude install build-essential zlibc libjpeg62-dev libfreetype6-dev
-
-.PHONY: default debdepends python-unpack python-build python-rebuild python-clean python \
- setuptools eggs pil-unpack pil-build pil-rebuild pil-clean pil buildout bootstrap \
- update update-nonet shell init otherinit
-
-python-unpack: $(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README
-$(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README:
- mkdir $(PYTHON_DIR)
- wget "$(PYTHON_URL)" -O $(PYTHON_DIR)/python.tgz
- tar -C $(PYTHON_DIR) -xzf $(PYTHON_DIR)/python.tgz
- rm -f $(PYTHON_DIR)/python.tgz
-
-python-build: $(PYTHON)
-$(PYTHON):
- cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && ./configure --prefix=$(BASEDIR)/$(PYTHON_DIR)
- cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make
- cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make install
-
-python-rebuild: python-clean python-build
-
-python-clean:
- cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make clean
- rm -f $(PYTHON)
-
-python: python-unpack python-build
-
-setuptools: $(EASY_INSTALL)
-$(EASY_INSTALL):
- mkdir $(PYTHON_DIR)/Extensions
- wget $(SETUPTOOLS_URL) -O $(PYTHON_DIR)/Extensions/ez_setup.py
- cd $(PYTHON_DIR)/Extensions && $(PYTHON) ez_setup.py
-
-eggs:
- $(EASY_INSTALL) ZopeSkel
- $(EASY_INSTALL) zc.buildout
-
-pil-unpack: $(PYTHON_DIR)/Extensions/Imaging-$(PIL_VERSION)/README
-$(PYTHON_DIR)/Extensions/Imaging-$(PIL_VERSION)/README:
- wget $(PIL_URL) -O $(PYTHON_DIR)/Extensions/pil.tgz
- tar -C $(PYTHON_DIR)/Extensions -xzf $(PYTHON_DIR)/Extensions/pil.tgz
- rm -f $(PYTHON_DIR)/Extensions/pil.tgz
+###########################################################################
+# Customization targets
-pil-build: $(PYTHON_DIR)/bin/pilconvert.py
-$(PYTHON_DIR)/bin/pilconvert.py:
- cd $(PYTHON_DIR)/Extensions/Imaging-$(PIL_VERSION) && $(PYTHON) setup.py build --force
- cd $(PYTHON_DIR)/Extensions/Imaging-$(PIL_VERSION) && $(PYTHON) setup.py install --force
+debdepends::
+.PHONY: debdepends
-pil-rebuild: pil-clean pil-build
+setup::
+.PHONY: setup
-pil-clean:
- rm -f $(PYTHON_DIR)/bin/pilconvert.py
+eggs::
+.PHONY: eggs
-pil: pil-unpack pil-build
+buildout::
+.PHONY: buildout
-buildout: buildout.cfg
-buildout.cfg:
- $(PASTER) create --no-interactive -t plone3_buildout . zope_password=admin
+init-hook::
+.PHONY: init-hook
-versions:
- @echo "# Add the following lines to [versions] in buildout.cfg to pin all packages"
- @bin/buildout -Novvvvv |sed -ne 's/^Picked: //p' | sort | uniq
+update-hook::
+.PHONY: update-hook
-bootstrap:
+bootstrap::
sed -i -e '1s/^#!.*\/python/#!$(subst /,\/,$(PYTHON))/' $(PYTHON_DIR)/bin/*
# $(PYTHON) bootstrap.py
$(PYTHON) -c 'from zc.buildout.buildout import main; main(["bootstrap"])'
+update:: update-hook
+ bin/buildout $(BUILDOUT_OPTS)
+
+define gitignore
+ _gitignore () { \
+ [ -r .gitignore ] || touch .gitignore; \
+ grep -qxF "$$1" .gitignore || echo "$$1" >>.gitignore; \
+ }; \
+ _gitignore
+endef
+.gitignore::
+ @echo "Updating .gitignore"
+ @$(gitignore) "*.pyc"
+ @$(gitignore) "*.egg-info/"
+ @$(gitignore) "/.env"
+
+define env
+ _env () { \
+ [ -r .env ] || touch .env; \
+ case "$$1" in \
+ PATH|PYTHONPATH) line="export $$1=\"$$2:\$$$$1\"" ;; \
+ *) line="export $$1=\"$$2\"" ;; \
+ esac; \
+ grep -qxF "$$line" .env || echo "$$line" >>.env; \
+ }; \
+ _env
+endef
+.env::
+ @echo "Updating .env"
+
+clean::
+ rm -f .gitignore .env
+.PHONY: clean
-.gitignore:
- @echo "python/" >.gitignore
- @echo "var/" >>.gitignore
- @echo "bin/" >>.gitignore
- @echo "develop-eggs/" >>.gitignore
- @echo "downloads/" >>.gitignore
- @echo "eggs/" >>.gitignore
- @echo "fake-eggs/" >>.gitignore
- @echo "parts/" >>.gitignore
- @echo "/.installed.cfg" >>.gitignore
- @echo "/bootstrap.py" >>.gitignore
- @echo "*.pyc" >>.gitignore
- @echo "*.egg-info/" >>.gitignore
+###########################################################################
+# internal targets
-shell:
- @PATH=$(BASEDIR)/$(PYTHON_DIR)/bin:$(BASEDIR)/bin:$$PATH $$SHELL
-init: python setuptools pil eggs buildout otherinit otherupdate bootstrap update .gitignore
+###########################################################################
+# user targets
-otherinit::
+init: setup eggs buildout init-hook update-hook bootstrap update .gitignore .env
-otherupdate::
+versions:
+ @echo "# Add the following lines to [versions] in buildout.cfg to pin all packages"
+ @bin/buildout -Novvvvv | sed -ne 's/^Picked: //p' | sort | uniq
-update: otherupdate
- bin/buildout
+shell:
+ @eval "`cat .env`"; $$SHELL
-update-nonet: otherupdate
- bin/buildout -No
+update-nonet: BUILDOUT_OPTS=-No
+update-nonet: update
--- /dev/null
+# -*- makefile -*-
+
+PYTHON_VERSION ?= 2.4.6
+PYTHON_URL ?= http://www.python.org/ftp/python/$(PYTHON_VERSION)/Python-$(PYTHON_VERSION).tgz
+SETUPTOOLS_URL ?= http://peak.telecommunity.com/dist/ez_setup.py
+
+###########################################################################
+
+PYTHON_DIR=python
+
+PYTHON = $(BASEDIR)/$(PYTHON_DIR)/bin/python
+EASY_INSTALL = $(BASEDIR)/$(PYTHON_DIR)/bin/easy_install
+PASTER = $(BASEDIR)/$(PYTHON_DIR)/bin/paster
+
+###########################################################################
+
+python-unpack: $(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README
+$(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README:
+ mkdir $(PYTHON_DIR)
+ wget "$(PYTHON_URL)" -O $(PYTHON_DIR)/python.tgz
+ tar -C $(PYTHON_DIR) -xzf $(PYTHON_DIR)/python.tgz
+ rm -f $(PYTHON_DIR)/python.tgz
+.PHONY: python-unpack
+
+python-build: $(PYTHON)
+$(PYTHON):
+ cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && ./configure --prefix=$(BASEDIR)/$(PYTHON_DIR)
+ cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make
+ cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make install
+.PHONY: python-build
+
+python-rebuild: python-clean python-build
+.PHONY: python-rebuild
+
+python-clean:
+ cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make clean
+ rm -f $(PYTHON)
+.PHONY: python-clean
+
+python: python-unpack python-build
+.PHONY: python
+
+setuptools: $(EASY_INSTALL)
+$(EASY_INSTALL):
+ mkdir $(PYTHON_DIR)/Extensions
+ wget $(SETUPTOOLS_URL) -O $(PYTHON_DIR)/Extensions/ez_setup.py
+ cd $(PYTHON_DIR)/Extensions && $(PYTHON) ez_setup.py
+.PHONY: setuptools
+
+pybase: python setuptools
+.PHONY: pybase
+
+###########################################################################
+
+debdepends::
+ aptitude install build-essential zlibc
+
+eggs::
+ $(EASY_INSTALL) zc.buildout
+
+.gitignore::
+ @$(gitignore) /python/
+
+.env::
+ @$(env) PATH $(BASEDIR)/$(PYTHON_DIR)/bin
+
+clean:: python-clean
+
+setup:: pybase
--- /dev/null
+# -*- makefile -*-
+
+ADMINUSER ?= admin
+ADMINPWD ?= admin
+EGGDIR ?= downloads
+
+ZOPEPROJECT = $(BASEDIR)/$(PYTHON_DIR)/bin/zopeproject
+
+buildout.cfg:
+ @[ -n "$(PROJECTNAME)" ] || (echo "PROJECTNAME not set"; exit 2)
+ @( \
+ mkdir $(BASEDIR)/temp-project && cd $(BASEDIR)/temp-project && \
+ echo "zopeproject --no-buildout \"$(PROJECTNAME)\"" && \
+ (echo "$(ADMINUSER)"; echo "$(ADMINPWD)"; echo "$(EGGDIR)") | $(ZOPEPROJECT) --no-buildout "$(PROJECTNAME)" && \
+ mv $(PROJECTNAME)/* $(BASEDIR)/ \
+ ) || ( rm -f temp-project; false )
+ @(rm -rf $(BASEDIR)/temp-project)
+ @echo
+
+###########################################################################
+
+eggs::
+ $(EASY_INSTALL) zopeproject
+
+buildout:: buildout.cfg
+
+bootstrap::
+ @[ -n "$(PROJECTNAME)" ] || (echo "PROJECTNAME not set"; exit 2)
+ @( \
+ cd bin && \
+ for script in ctl debug; do \
+ ( \
+ echo "#!/bin/sh"; \
+ echo 'cd "`dirname "$$0"`/.."'; \
+ echo "exec bin/$(PROJECTNAME)-$$script"' "$$@"' \
+ ) > $$script; \
+ chmod ugo+rx $$script; \
+ echo "Generated script '$(BASEDIR)/bin/$$script'."; \
+ done \
+ )
+
+.gitignore::
+ @$(gitignore) "/bin/"
+ @$(gitignore) "/develop-eggs/"
+ @$(gitignore) "/downloads/"
+ @$(gitignore) "/log/"
+ @$(gitignore) "/var/"
+ @$(gitignore) "/.installed.cfg"
+
+
+.env::
+ @$(env) PATH $(BASEDIR)/bin
+
+clean::
+ rm -rf log var develop-eggs parts