| 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 += all |
| 19 | CMD-all ?= build |
| 20 | |
| 21 | PYTARGETS += clean |
| 22 | OPTS-clean ?= --all |
| 23 | clean-hook::; rm -f MANIFEST RELEASE |
| 24 | |
| 25 | PYTARGETS += dist |
| 26 | CMD-dist ?= sdist |
| 27 | OPTS-dist += --dist-dir . |
| 28 | |
| 29 | PYTARGETS += install |
| 30 | OPTS-install += --prefix $(prefix) |
| 31 | |
| 32 | PYTARGETS += check |
| 33 | |
| 34 | ###-------------------------------------------------------------------------- |
| 35 | ### Interfacing `setup.py' to make. |
| 36 | |
| 37 | pysetup = $(PYTHON) setup.py \ |
| 38 | $(if $(filter-out undefined,$(origin CMD-$1)),$(CMD-$1),$1) \ |
| 39 | $(OPTS-$1) |
| 40 | |
| 41 | $(foreach t, $(PYTARGETS), $t-hook):: %: |
| 42 | $(PYTARGETS):: %: %-hook setup.py |
| 43 | $(call pysetup,$*) |
| 44 | |
| 45 | .PHONY: $(PYTARGETS) |
| 46 | |
| 47 | ###-------------------------------------------------------------------------- |
| 48 | ### Release builds. |
| 49 | |
| 50 | distcheck: |
| 51 | rm -rf _distcheck |
| 52 | $(PYTHON) setup.py sdist --dist-dir _distcheck |
| 53 | cd _distcheck && tar xvfz $(distdir).tar.gz |
| 54 | cd _distcheck/$(distdir) && make && make check && make dist |
| 55 | cp _distcheck/$(distdir)/$(distdir).tar.gz . |
| 56 | rm -rf _distcheck |
| 57 | |
| 58 | ###----- That's all, folks -------------------------------------------------- |