Target cleanup and extended help system
Stefan Bund [Wed, 4 Aug 2010 12:10:01 +0000 (14:10 +0200)]
Makefile.buildout
Makefile.master
Makefile.pil
Makefile.pybase
Makefile.zope3-buildout

index 0846414..4f71535 100644 (file)
@@ -105,9 +105,24 @@ bootstrap::
        sed -i -e '1s/^#!.*\/python/#!$(subst /,\/,$(PYTHON))/' $(PYTHON_DIR)/bin/*
        $(PYTHON) -c 'from zc.buildout.buildout import main; main(["bootstrap"])'
 
+update::
+       bin/buildout $(BUILDOUT_OPTS)
+
 .gitignore::
+       @$(gitignore) "*.egg-info/"
        @$(gitignore) "/buildout-net.cfg"
        @$(gitignore) "/buildout-nonet.cfg"
 
 clean::
        rm -f buildout-net.cfg buildout-nonet.cfg
+
+versions:
+       @echo "# Add the following lines to [versions] in buildout.cfg to pin all packages"
+       @bin/buildout -vvvvv | sed -ne 's/^Picked: //p' | sort | uniq 
+.PHONY: versions
+
+fullhelp::
+       @echo "    versions"
+       @echo "        Generate lines to be added to 'buildout.cfg' to pin all package"
+       @echo "        versions."
+       @echo
index 136a906..4d69e96 100644 (file)
 #        <other>      Set variable to <value>
 # 
 # clean::
-#     Called to clean up all generated files
+#     Called to clean up all unimportant generated files. This includes all files
+#     which may be recreated by calling 'init'
+#
+# shorthelp::
+#     Called to provide an overview of important target (this is the default target)
+#
+# fullhelp::
+#     Called to create the list of supplementary targets.
+#
+# varhelp::
+#     Called to create the list of Makefile variables.
 #
 
 ###########################################################################
@@ -66,7 +76,7 @@ define httpget
        name="$${1##*/}";                                                       \
        target="$$2";                                                           \
        [ -n "$$target" ] || target="$$name";                                   \
-       cache="$(DLCACHE)/$$name";                                              \
+       cache="$(BASEDIR)/$(DLCACHE)/$$name";                                   \
        if [ -r "$$cache" ]; then                                               \
            echo "Fetching '$$name' from cache.";                               \
        else                                                                    \
@@ -95,9 +105,9 @@ shorthelp::
        @echo
        @echo "MAIN TARGETS"
        @echo
-       @echo "    shorthelp"
+       @echo "    shorthelp (default target)"
        @echo "    help"
-       @echo "        Summary of important / all user targets"
+       @echo "        Summary of important targets / complete help."
        @echo
        @echo "    debdepends"
        @echo "        Install debian packages via 'aptitude' needed to satisy build"
@@ -121,19 +131,16 @@ shorthelp::
        @echo "        for the local buildout."
        @echo
        @echo "    clean"
-       @echo "        Remove all unimportant (!) generated files. This target will leave"
-       @echo "        only those files which are to be checked into version control."
-       @echo "        calling 'make init' or 'make init-nonet' will rebuild the buildout."
+       @echo "        Remove all unimportant (!) generated files (the remaining files are"
+       @echo "        those which may be changed and should be managed as part of the"
+       @echo "        project source-code). calling 'make init' or 'make init-nonet' will"
+       @echo "        rebuild the development environment."
        @echo
 .PHONY: shorthelp
 
-help:: shorthelp
+fullhelp::
        @echo
-       @echo "SECONDARY TARGETS"
-       @echo
-       @echo "    versions"
-       @echo "        Generate lines to be added to 'buildout.cfg' to pin all package"
-       @echo "        versions."
+       @echo "SUPPLEMENTARY TARGETS"
        @echo
        @echo "    cleancache"
        @echo "        purge the download cache"
@@ -146,6 +153,20 @@ help:: shorthelp
        @echo "        target purges the download cache to ensure, no obsolete files are"
        @echo "        left."
        @echo
+.PHONY: fullhelp
+
+varhelp::
+       @echo
+       @echo "MAKEFILE VARIABLES"
+       @echo
+       @echo "    DLCACHE ($(DLCACHE))"
+       @echo "        Name of the download-cache subdirectory. This directory may be"
+       @echo "        persisted e.g. by checking into version control (together with"
+       @echo "        the source code or into as a separate repository or by saving into"
+       @echo "        an archive. A persistent cache allows the setup to be completely"
+       @echo "        reproducible and network independent."
+       @echo
+.PHONY: varhelp
 
 debdepends::
 .PHONY: debdepends
@@ -170,7 +191,6 @@ bootstrap::
 .PHONY: bootstrap
 
 update:: update-hook
-       bin/buildout $(BUILDOUT_OPTS)
 .PHONY: update
 
 define gitignore
@@ -182,8 +202,6 @@ define gitignore
 endef
 .gitignore::
        @echo "Updating .gitignore."
-       @$(gitignore) "*.pyc"
-       @$(gitignore) "*.egg-info/"
        @$(gitignore) "/.env"
 
 define env
@@ -214,11 +232,6 @@ init-nonet: HTTPGET_NONET=1
 init-nonet: init
 .PHONY: init-nonet
 
-versions:
-       @echo "# Add the following lines to [versions] in buildout.cfg to pin all packages"
-       @bin/buildout -vvvvv | sed -ne 's/^Picked: //p' | sort | uniq 
-.PHONY: versions
-
 shell:
        @eval "`cat .env`"; $$SHELL
 .PHONY: shell
@@ -232,3 +245,8 @@ cleancache:
 
 upgrade: clean cleancache init
 .PHONY: upgrade
+
+help:
+       @[ -n `which less` ] && $(MAKE) -s shorthelp fullhelp varhelp | less \
+               || $(MAKE) -s shorthelp fullhelp varhelp
+.PHONY: help
\ No newline at end of file
index ca16bbd..9f1c9cc 100644 (file)
@@ -35,8 +35,17 @@ debdepends::
 
 setup:: pil
 
-help::
+fullhelp::
        @echo "    pil-rebuild"
        @echo "        recompile PIL plugin from source. This may be needed after"
        @echo "        upgrading the host distribution."
+       @echo
+
+varhelp::
+       @echo "    PIL_VERSION ($(PIL_VERSION))"
+       @echo "        Version of the Python Imaging Library to install."
+       @echo
+       @echo "    PIL_URL ($(PIL_URL))"
+       @echo "        URL to download the Python Imaging Library from. The default value"
+       @echo "        is automatically generated from PIL_VERSION."
        @echo
\ No newline at end of file
index 6a7a0b5..325c39d 100644 (file)
@@ -3,11 +3,10 @@
 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_DIR ?= python
-
 PYTHON       = $(BASEDIR)/$(PYTHON_DIR)/bin/python
 EASY_INSTALL = $(BASEDIR)/$(PYTHON_DIR)/bin/easy_install
 PIP          = $(BASEDIR)/$(PYTHON_DIR)/bin/pip
@@ -125,7 +124,8 @@ eggs::
        @$(install) zc.buildout
 
 .gitignore::
-       @$(gitignore) /python/
+       @$(gitignore) "*.pyc"
+       @$(gitignore) "/python/"
 
 .env::
        @$(env) PATH $(BASEDIR)/$(PYTHON_DIR)/bin
@@ -139,8 +139,23 @@ PIP_CACHE_FILES := $(shell cd $(DLCACHE)/pip; ls *.tar.gz | grep -vF '%2F')
 
 init-nonet: PIP_OPTS  = --no-index $(patsubst %,--find-link=file://$(BASEDIR)/$(DLCACHE)/pip/%,$(PIP_CACHE_FILES))
 
-help::
+fullhelp::
        @echo "    python-rebuild"
        @echo "        recompile python from source. This may be needed after"
        @echo "        upgrading the host distribution."
-       @echo
\ No newline at end of file
+       @echo
+
+varhelp::
+       @echo "    PYTHON_VERSION ($(PYTHON_VERSION))"
+       @echo "        Python version to download and compile."
+       @echo
+       @echo "    PYTHON_URL ($(PYTHON_URL))"
+       @echo "        URL to download python from. The default value is automatically"
+       @echo "        generated from PYTHON_VERSION."
+       @echo
+       @echo "    SETUPTOOLS_URL ($(SETUPTOOLS_URL))"
+       @echo "        URL to download 'ez_setup.py' from."
+       @echo
+       @echo "    PYTHON_DIR ($(PYTHON_DIR))"
+       @echo "        Name of subdirectory for the local python installation."
+       @echo
index 920eb71..9febf85 100644 (file)
@@ -54,3 +54,21 @@ bootstrap::
 
 clean::
        rm -rf bin develop-eggs $(EGGDIR) parts .installed.cfg
+
+varhelp::
+       @echo "    PROJECTNAME ($(PROJECTNAME))"
+       @echo "        Name of the project egg. Must be set before creating the initial"
+       @echo "         buildout."
+       @echo
+       @echo "    ADMINUSER ($(ADMINUSER))"
+       @echo "        Name of the default zope3 administrator. Only honored when creating"
+       @echo "        a new buildout. Later, configure in 'site.zcml'."
+       @echo
+       @echo "    ADMINPWD ($(ADMINPWD))"
+       @echo "        Password of the default zope3 administrator. Only honored when"
+       @echo "        creating a new buildout. Later, configure in 'site.zcml'."
+       @echo
+       @echo "    EGGDIR ($(EGGDIR))"
+       @echo "        Directory for eggs downloaded by 'buildout'. Only honored when"
+       @echo "        creating a new buildout. Later, configure in 'buildout.cfg'."
+       @echo