chiark / gitweb /
09dd7b0702247bbb837ee67b6f7217c1b995c929
[mLib] / pysetup.mk
1 ### -*-makefile-*-
2 ###
3 ### Standard Makefile for Python packages.
4
5 default: all
6
7 PYTHON                  ?= python
8 prefix                  ?= /usr/local
9
10 ###--------------------------------------------------------------------------
11 ### Version information.
12
13 distdir                 := $(shell $(PYTHON) setup.py -q distdir)
14
15 ###--------------------------------------------------------------------------
16 ### Useful targets implemented by the `setup.py' program.
17
18 PYTARGETS               += gen
19 CMD-gen                 ?= build_gen
20
21 PYTARGETS               += all
22 CMD-all                 ?= build
23 all:: gen
24
25 PYTARGETS               += clean
26 OPTS-clean              ?= --all
27 clean-hook::; rm -f MANIFEST RELEASE
28
29 PYTARGETS               += dist
30 CMD-dist                ?= sdist
31 OPTS-dist               += --dist-dir .
32
33 PYTARGETS               += install
34 OPTS-install            += --prefix $(prefix)
35
36 PYTARGETS               += check
37
38 ###--------------------------------------------------------------------------
39 ### Interfacing `setup.py' to make.
40
41 pysetup = $(PYTHON) setup.py \
42         $(if $(filter-out undefined,$(origin CMD-$1)),$(CMD-$1),$1) \
43         $(OPTS-$1)
44
45 $(foreach t, $(PYTARGETS), $t-hook):: %:
46 $(PYTARGETS):: %: %-hook setup.py
47         $(call pysetup,$*)
48
49 .PHONY: $(PYTARGETS)
50
51 ###--------------------------------------------------------------------------
52 ### Release builds.
53
54 distcheck:
55         rm -rf _distcheck
56         $(PYTHON) setup.py sdist --dist-dir _distcheck
57         cd _distcheck && tar xvfz $(distdir).tar.gz
58         cd _distcheck/$(distdir) && make && make check && make dist
59         cp _distcheck/$(distdir)/$(distdir).tar.gz .
60         rm -rf _distcheck
61
62 ###----- That's all, folks --------------------------------------------------