# Change this to use a different Python interpreter,
# or use, e.g. make PYTHON=my-python
PYTHON?=python
# Change this to 1 to rebuild the documentation.
UPDATE_DOCS?=0
# This makefile is a mess, but never mind.
VERSION=0.2
MODULES=src/*.py src/*/*.py src/cpython/*.pyx src/cpython/*.c
DOCUMENTED=$(MODULES)
ifeq ($(UPDATE_DOCS), 1)
DOCS=doc/auto/index.html doc/tutorial.html doc/types.html
else
DOCS=
endif
DIST=dist/sizer-$(VERSION).tar.gz
all: modules doc
doc: $(DOCS)
dist: $(DIST)
install: all
$(PYTHON) setup.py install
modules: build
build: $(MODULES)
$(PYTHON) setup.py build
$(PYTHON) setup.py build_ext
# Should change this to something sensible eventually...
DOC_PATH1=home/nick/sizer
DOC_PATH=/$(DOC_PATH1)
# Produce the current directory without a / at the beginning
PWD1:=$(shell echo $(PWD)|sed "s/\///")
QUOTED_DOC=$(subst /,\/,$(DOC_PATH1))
QUOTED_PWD=$(subst /,\/,$(PWD1))
doc/auto/index.html: $(DOCUMENTED)
happydoc -d doc/auto $(DOCUMENTED)
mkdir -p doc/auto/$(DOC_PATH1)
cp -r doc/auto/$(PWD1)/* doc/auto/$(DOC_PATH1)
mv doc/auto/index.html doc/auto/index.2
sed "s/$(QUOTED_PWD)/$(QUOTED_DOC)/g" doc/auto/index.2>doc/auto/index.html
rm doc/auto/index.2
rm -r doc/auto/$(PWD1)
#
# This is ugly sed nonsense to semi-automatically put links in doc/*.in.
#
# Replace x.y with a link to y in module x
# or x with a link to module x
# link will also work.
# Links can be module, module.func, module.Class or module.Class.func.
tutorial: doc/tutorial.html
MODULE_PATTERN = ]*\)>\([^<]*\)<\/auto>
MODULE_REPLACE = \2<\/a>
FUNC_PATTERN = ]*\)\.\([a-z][^\.>]*\)>\([^<]*\)<\/auto>
FUNC_REPLACE = \3<\/a>
CLASS_PATTERN = ]*\)\.\([A-Z][^\.>]*\)>\([^<]*\)<\/auto>
CLASS_REPLACE = \3<\/a>
METHOD_PATTERN = ]*\)\.\([A-Z][^\.>]*\)\.\([a-z][^\.>]*\)>\([^<]*\)<\/auto>
METHOD_REPLACE = \4<\/a>
# Replace foo with foo
EXPAND_PATTERN = \([^<]*\)<\/auto>
EXPAND_REPLACE = \1<\/auto>
doc/tutorial.html: doc/tutorial.html.in Makefile
sed "s/$(EXPAND_PATTERN)/$(EXPAND_REPLACE)/g" < doc/tutorial.html.in | \
sed "s/$(MODULE_PATTERN)/$(MODULE_REPLACE)/g" | \
sed "s/$(FUNC_PATTERN)/$(FUNC_REPLACE)/g" | \
sed "s/$(CLASS_PATTERN)/$(CLASS_REPLACE)/g" | \
sed "s/$(METHOD_PATTERN)/$(METHOD_REPLACE)/g" > doc/tutorial.html
# Put links to Python CVS in HTML files.
PYTHON_ROOT=http:\/\/cvs.sf.net\/viewcvs.py\/python\/python\/dist\/src
%: %.cvs.in Makefile
sed "s/link(\([^):]*\))/\1<\/a>/g" < $(<) > $(@)
clean: doc/tutorial.html.in
rm -f doc/tutorial.html doc/types.html
rm -f `find doc/auto -name "*.html"`
rm -rf build
$(PYTHON) setup.py clean
cleanall: clean
rm -f `find . -name "*~" -or -name "*.pyc" -or -name "*.pyo"`
doc/internals.dvi: FORCE
cd doc && latex -shell-escape internals.tex
FORCE:
doc/internals.ps: doc/internals.dvi
cd doc && dvips internals.dvi
doc/internals.pdf: doc/internals.dvi
cd doc && dvipdf internals.dvi
$(DIST): FORCE doc doc/internals.ps
rm -f $(DIST)
$(PYTHON) setup.py sdist --formats=gztar