pysetup.mk: Makefile fragment for interfacing to `setup.py'.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 15 Jun 2013 21:21:21 +0000 (22:21 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 16 Jun 2013 16:35:22 +0000 (17:35 +0100)
Makefile.am
pysetup.mk [new file with mode: 0644]

index ee272b3..c397447 100644 (file)
@@ -92,7 +92,8 @@ dist_pkgdata_SCRIPTS  += install-ac
 dist_pkgdata_SCRIPTS   += maninst
 
 ## Python support stuff.
-dist_pkgdata_SCRIPTS   += mdwsetup.py
+dist_pkgdata_DATA      += mdwsetup.py
+dist_pkgdata_DATA      += pysetup.mk
 
 ## confsubst
 pkgdata_SCRIPTS                += confsubst
diff --git a/pysetup.mk b/pysetup.mk
new file mode 100644 (file)
index 0000000..0e7a218
--- /dev/null
@@ -0,0 +1,58 @@
+### -*-makefile-*-
+###
+### Standard Makefile for Python packages.
+
+default: all
+
+PYTHON                 ?= python
+prefix                 ?= /usr/local
+
+###--------------------------------------------------------------------------
+### Version information.
+
+distdir                        := $(shell $(PYTHON) setup.py -q distdir)
+
+###--------------------------------------------------------------------------
+### Useful targets implemented by the `setup.py' program.
+
+PYTARGETS              += all
+CMD-all                        ?= build
+
+PYTARGETS              += clean
+OPTS-clean             ?= --all
+clean-hook::; rm -f MANIFEST RELEASE
+
+PYTARGETS              += dist
+CMD-dist               ?= sdist
+OPTS-dist              += --dist-dir .
+
+PYTARGETS              += install
+OPTS-install           += --prefix $(prefix)
+
+PYTARGETS              += check
+
+###--------------------------------------------------------------------------
+### Interfacing `setup.py' to make.
+
+pysetup = $(PYTHON) setup.py \
+       $(if $(filter-out undefined,$(origin CMD-$1)),$(CMD-$1),$1) \
+       $(OPTS-$1)
+
+$(foreach t, $(PYTARGETS), $t-hook):: %:
+$(PYTARGETS):: %: %-hook setup.py
+       $(call pysetup,$*)
+
+.PHONY: $(PYTARGETS)
+
+###--------------------------------------------------------------------------
+### Release builds.
+
+distcheck:
+       rm -rf _distcheck
+       $(PYTHON) setup.py sdist --dist-dir _distcheck
+       cd _distcheck && tar xvfz $(distdir).tar.gz
+       cd _distcheck/$(distdir) && make && make check && make dist
+       cp _distcheck/$(distdir)/$(distdir).tar.gz .
+       rm -rf _distcheck
+
+###----- That's all, folks --------------------------------------------------