pysetup.mk: Add an explicit `gen' target, and make `all' depend on it.
[cfd] / pysetup.mk
CommitLineData
1a7628a4
MW
1### -*-makefile-*-
2###
3### Standard Makefile for Python packages.
4
5default: all
6
7PYTHON ?= python
8prefix ?= /usr/local
9
10###--------------------------------------------------------------------------
11### Version information.
12
13distdir := $(shell $(PYTHON) setup.py -q distdir)
14
15###--------------------------------------------------------------------------
16### Useful targets implemented by the `setup.py' program.
17
36bcba75
MW
18PYTARGETS += gen
19CMD-gen ?= build_gen
20
1a7628a4
MW
21PYTARGETS += all
22CMD-all ?= build
36bcba75 23all:: gen
1a7628a4
MW
24
25PYTARGETS += clean
26OPTS-clean ?= --all
27clean-hook::; rm -f MANIFEST RELEASE
28
29PYTARGETS += dist
30CMD-dist ?= sdist
31OPTS-dist += --dist-dir .
32
33PYTARGETS += install
34OPTS-install += --prefix $(prefix)
35
36PYTARGETS += check
37
38###--------------------------------------------------------------------------
39### Interfacing `setup.py' to make.
40
41pysetup = $(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
54distcheck:
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 --------------------------------------------------