From: Mark Wooding Date: Sat, 15 Jun 2013 21:53:22 +0000 (+0100) Subject: Overhaul build system using new `cfd' machinery. X-Git-Tag: 1.0.4~4 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib-python/commitdiff_plain/976d8e49a3e4523566c05794a7bf1771b70eb1cd Overhaul build system using new `cfd' machinery. --- diff --git a/.gitignore b/.gitignore index 359d09e..fd89164 100644 --- a/.gitignore +++ b/.gitignore @@ -1,19 +1,7 @@ -deb-build -atom.c -base32.c base32.pyx -base64.c base64.pyx -build-stamp -crc32.c -hex.c hex.pyx -report.c -select.c -sym.c -unihash.c build -.gdbinit MANIFEST dist mLib.c @@ -21,5 +9,4 @@ COPYING mdwsetup.py *.pyc auto-version -RELEASE -python-build-stamp-* +pysetup.mk diff --git a/.links b/.links index e25ac67..4e00440 100644 --- a/.links +++ b/.links @@ -1,3 +1,4 @@ COPYING auto-version mdwsetup.py +pysetup.mk diff --git a/MANIFEST.in b/MANIFEST.in index 9bd6611..43e5919 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ -include COPYING RELEASE auto-version mdwsetup.py +include COPYING RELEASE auto-version mdwsetup.py pysetup.mk include mLib.pyx defs.pxi utils.pyx include codec.pyx.in grim.h atom.h array.h atom-base.c array.c Makefile include lbuf.pyx pkbuf.pyx mapping.pyx mdup.pyx diff --git a/Makefile b/Makefile index 7963e52..b9f9347 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,2 @@ -## Makefile - -PYTHON = python -prefix = /usr/local - -GEN = base64.pyx base32.pyx hex.pyx - -all: setup.py - $(PYTHON) setup.py build - -clean: setup.py - $(PYTHON) setup.py clean - rm -rf build - rm -f mLib.c $(GEN) MANIFEST - -dist: setup.py - $(PYTHON) setup.py sdist - -install: setup.py - $(PYTHON) setup.py install --prefix $(prefix) - -.PHONY: all clean dist install +### -*-makefile-*- +include pysetup.mk diff --git a/defs.pxi b/defs.pxi index c0b304a..e7086b7 100644 --- a/defs.pxi +++ b/defs.pxi @@ -23,7 +23,8 @@ ### along with mLib/Python; if not, write to the Free Software Foundation, ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -###----- C library ---------------------------------------------------------- +###-------------------------------------------------------------------------- +### C library. cdef extern from 'errno.h': int errno @@ -42,7 +43,8 @@ cdef extern from 'string.h': char *strerror(int err) size_t strlen(char *p) -###----- Unix interface ----------------------------------------------------- +###-------------------------------------------------------------------------- +### Unix interface. cdef extern from 'sys/types.h': pass @@ -82,7 +84,8 @@ cdef extern from 'netdb.h': char *h_addr int h_errno -###----- Python ------------------------------------------------------------- +###-------------------------------------------------------------------------- +### Python. cdef extern from 'Python.h': @@ -103,7 +106,8 @@ cdef extern from 'Python.h': void Py_INCREF(PyObject *obj) void Py_DECREF(PyObject *obj) -###----- mLib basic stuff --------------------------------------------------- +###-------------------------------------------------------------------------- +### mLib basic stuff. cdef extern from 'mLib/alloc.h': char *xstrdup(char *p) @@ -120,12 +124,14 @@ cdef extern from 'mLib/dstr.h': void DCREATE(dstr *d) void dstr_destroy(dstr *d) -###----- CRC32 -------------------------------------------------------------- +###-------------------------------------------------------------------------- +### CRC32. cdef extern from 'mLib/crc32.h': uint32 c_crc32 "crc32" (uint32 a, void *p, int sz) -###----- Universal hashing -------------------------------------------------- +###-------------------------------------------------------------------------- +### Universal hashing. cdef extern from 'mLib/unihash.h': ctypedef struct unihash_info: @@ -135,7 +141,8 @@ cdef extern from 'mLib/unihash.h': uint32 unihash_hash(unihash_info *i, uint32 a, void *p, int sz) unihash_info unihash_global -###----- Symbol tables ------------------------------------------------------ +###-------------------------------------------------------------------------- +### Symbol tables. cdef extern from 'mLib/sym.h': ctypedef struct sym_table: @@ -153,7 +160,8 @@ cdef extern from 'mLib/sym.h': void sym_mkiter(sym_iter *i, sym_table *t) void *sym_next(sym_iter *i) -###----- String utilities --------------------------------------------------- +###-------------------------------------------------------------------------- +### String utilities. cdef extern from 'mLib/str.h': enum: @@ -167,7 +175,8 @@ cdef extern from 'mLib/str.h': cdef extern from 'mLib/versioncmp.h': int _versioncmp "versioncmp"(char *va, char *vb) -###----- Form-urlencoding functions ----------------------------------------- +###-------------------------------------------------------------------------- +### Form-urlencoding functions. cdef extern from 'mLib/url.h': struct url_ectx: @@ -184,7 +193,8 @@ cdef extern from 'mLib/url.h': void url_initdec(url_dctx *ctx, char *p) int url_dec(url_dctx *ctx, dstr *n, dstr *v) -###----- Atom stuff --------------------------------------------------------- +###-------------------------------------------------------------------------- +### Atom stuff. ## Atoms. ## @@ -221,14 +231,16 @@ cdef extern from 'mLib/assoc.h': void assoc_mkiter(assoc_iter *i, assoc_table *t) void *assoc_next(assoc_iter *i) -###----- Double-ended arrays ------------------------------------------------ +###-------------------------------------------------------------------------- +### Double-ended arrays. cdef extern from 'array.h': void da_pysetup() PyTypeObject da_pytype PyTypeObject daiter_pytype -###----- Line buffer -------------------------------------------------------- +###-------------------------------------------------------------------------- +### Line buffer. cdef extern from 'mLib/lbuf.h': cdef struct lbuf: @@ -249,7 +261,8 @@ cdef extern from 'mLib/lbuf.h': void (*func)(char *s, size_t len, void *arg), void *arg) void lbuf_destroy(lbuf *b) -###----- Packet buffer ------------------------------------------------------ +###-------------------------------------------------------------------------- +### Packet buffer. cdef extern from 'mLib/pkbuf.h': ctypedef struct pkbuf: @@ -267,7 +280,8 @@ cdef extern from 'mLib/pkbuf.h': void *arg) void pkbuf_destroy(pkbuf *b) -###----- Select stuff ------------------------------------------------------- +###-------------------------------------------------------------------------- +### Select stuff. ## Basics. cdef extern from 'mLib/sel.h': @@ -373,7 +387,8 @@ cdef extern from 'mLib/ident.h': void *arg) void ident_abort(ident_request *rq) -###----- Error reporting ---------------------------------------------------- +###-------------------------------------------------------------------------- +### Error reporting. cdef extern from 'mLib/quis.h': void _ego "ego"(char *prog) @@ -382,7 +397,8 @@ cdef extern from 'mLib/quis.h': cdef extern from 'mLib/report.h': void _moan "moan"(char *f, char *msg) -###----- File comparison ---------------------------------------------------- +###-------------------------------------------------------------------------- +### File comparison. cdef extern from 'mLib/fwatch.h': ctypedef struct fwatch: @@ -392,7 +408,8 @@ cdef extern from 'mLib/fwatch.h': int fwatch_update(fwatch *f, char *name) int fwatch_updatefd(fwatch *f, int fd) -###----- File descriptor hacking -------------------------------------------- +###-------------------------------------------------------------------------- +### File descriptor hacking. cdef extern from 'mLib/fdflags.h': int _fdflags "fdflags"(int fd, @@ -409,13 +426,15 @@ cdef extern from 'mLib/mdup.h': int want int _mdup "mdup"(mdup_fd *v, size_t n) -###----- Daemon utilities --------------------------------------------------- +###-------------------------------------------------------------------------- +### Daemon utilities. cdef extern from 'mLib/daemonize.h': int _daemonize "daemonize"() void _detachtty "detachtty"() -###----- Internal utilities ------------------------------------------------- +###-------------------------------------------------------------------------- +### Internal utilities. cdef extern from 'grim.h': int PSIZEOF(void *x) diff --git a/mLib.pyx b/mLib.pyx index 6b8b2ea..2016173 100644 --- a/mLib.pyx +++ b/mLib.pyx @@ -23,11 +23,13 @@ ### along with mLib/Python; if not, write to the Free Software Foundation, ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -###----- External stuff ----------------------------------------------------- +###-------------------------------------------------------------------------- +### External stuff. include 'defs.pxi' -###----- Various facilities ------------------------------------------------- +###-------------------------------------------------------------------------- +### Various facilities. ## Internal utilities. include 'utils.pyx' @@ -77,7 +79,8 @@ include 'selbuf.pyx' include 'selpk.pyx' include 'ident.pyx' -###----- Set-up stuff ------------------------------------------------------- +###-------------------------------------------------------------------------- +### Set-up stuff. cdef object _tyobj(PyTypeObject *ty): cdef PyObject *obj diff --git a/setup.py b/setup.py index b84fb43..66aafc5 100755 --- a/setup.py +++ b/setup.py @@ -6,24 +6,23 @@ import mdwsetup as MS MS.pkg_config('mLib', '2.1.0') -MS.derive('base64.pyx', 'codec.pyx.in', - {'CLASS': 'Base64', 'PREFIX': 'base64'}) -MS.derive('base32.pyx', 'codec.pyx.in', - {'CLASS': 'Base32', 'PREFIX': 'base32'}) -MS.derive('hex.pyx', 'codec.pyx.in', - {'CLASS': 'Hex', 'PREFIX': 'hex'}) - mLib = DC.Extension('mLib', ['mLib.pyx', 'atom-base.c', 'array.c'], ##extra_compile_args = ['-O0'], include_dirs = MS.uniquify(MS.INCLUDEDIRS), library_dirs = MS.uniquify(MS.LIBDIRS), libraries = MS.uniquify(MS.LIBS)) -DC.setup(name = 'mLib-python', - version = MS.auto_version(), +MS.setup(name = 'mLib-python', description = 'Python interface to mLib utilities library', author = 'Straylight/Edgeware', author_email = 'mdw@distorted.org.uk', license = 'GNU General Public License', ext_modules = [mLib], + genfiles = [MS.Derive('base64.pyx', 'codec.pyx.in', + {'CLASS': 'Base64', 'PREFIX': 'base64'}), + MS.Derive('base32.pyx', 'codec.pyx.in', + {'CLASS': 'Base32', 'PREFIX': 'base32'}), + MS.Derive('hex.pyx', 'codec.pyx.in', + {'CLASS': 'Hex', 'PREFIX': 'hex'})], + cleanfiles = ['mLib.c'], cmdclass = { 'build_ext': PXD.build_ext })