libstand: Consolidate tftp sendrecv into net.c sendrecv
[unleashed.git] / share / mk / cython.mk
blob414051827eb88c29f9c718b69955d6af9513e54c
1 # RCSid:
2 # $Id: cython.mk,v 1.6 2014/10/15 06:23:51 sjg Exp $
4 # @(#) Copyright (c) 2014, Simon J. Gerraty
6 # This file is provided in the hope that it will
7 # be of use. There is absolutely NO WARRANTY.
8 # Permission to copy, redistribute or otherwise
9 # use this file is hereby granted provided that
10 # the above copyright notice and this notice are
11 # left intact.
13 # Please send copies of changes and bug-fixes to:
14 # sjg@crufty.net
17 # this is what we build
18 CYTHON_MODULE = ${CYTHON_MODULE_NAME}${CYTHON_PYVERSION}.so
20 CYTHON_MODULE_NAME?= it
21 CYTHON_SRCS?= ${CYTHON_MODULE_NAME}.pyx
23 # this is where we save generated src
24 CYTHON_SAVEGENDIR?= ${.CURDIR}/gen
26 # pyprefix is where python bits are
27 # which may not be where we want to put ours (prefix)
28 .if exists(/usr/pkg/include)
29 pyprefix?= /usr/pkg
30 .endif
31 pyprefix?= /usr/local
33 PYTHON_VERSION?= 2.7
34 PYTHON_H?= ${pyprefix}/include/python${PYTHON_VERSION}/Python.h
35 PYVERSION:= ${PYTHON_VERSION:C,\..*,,}
37 # set this empty if you don't want to handle multiple versions
38 .if !defined(CYTHON_PYVERSION)
39 CYTHON_PYVERSION:= ${PYVERSION}
40 .endif
42 CFLAGS+= -I${PYTHON_H:H}
44 CYTHON_GENSRCS= ${CYTHON_SRCS:R:S,$,${CYTHON_PYVERSION}.c,}
45 SRCS+= ${CYTHON_GENSRCS}
47 .SUFFIXES: .pyx .c .So
49 CYTHON?= ${pyprefix}/bin/cython
51 # if we don't have cython we can use pre-generated srcs
52 .if ${type ${CYTHON} 2> /dev/null || echo:L:sh:M/*} == ""
53 .PATH: ${CYTHON_SAVEGENDIR}
54 .else
56 .if !empty(CYTHON_PYVERSION)
57 .for c in ${CYTHON_SRCS}
58 ${c:R}${CYTHON_PYVERSION}.${c:E}: $c
59 ln -sf ${.ALLSRC:M*pyx} ${.TARGET}
60 .endfor
61 .endif
63 .pyx.c:
64 ${CYTHON} ${CYTHON_FLAGS} -${PYVERSION} -o ${.TARGET} ${.IMPSRC}
67 save-gen: ${CYTHON_GENSRCS}
68 mkdir -p ${CYTHON_SAVEGENDIR}
69 cp -p ${.ALLSRC} ${CYTHON_SAVEGENDIR}
71 .endif
73 COMPILE.c?= ${CC} -c ${CFLAGS}
75 .c.So:
76 ${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
78 ${CYTHON_MODULE}: ${SRCS:S,.c,.So,}
79 ${CC} ${CC_SHARED:U-shared} -o ${.TARGET} ${.ALLSRC:M*.So} ${LDADD}
81 # conf.host_target() is limited to uname -m rather than uname -p
82 _HOST_MACHINE!= uname -m
83 .if ${HOST_TARGET:M*${_HOST_MACHINE}} == ""
84 PY_HOST_TARGET:= ${HOST_TARGET:S,${_HOST_ARCH:U${uname -p:L:sh}}$,${_HOST_MACHINE},}
85 .endif
87 MODULE_BINDIR?= ${.CURDIR:H}/${PY_HOST_TARGET:U${HOST_TARGET}}
89 build-cython-module: ${CYTHON_MODULE}
91 install-cython-module: ${CYTHON_MODULE}
92 ${INSTALL} -d ${DESTDIR}${MODULE_BINDIR}
93 ${INSTALL} -m 755 ${.ALLSRC} ${DESTDIR}${MODULE_BINDIR}
95 CLEANFILES+= *.So ${CYTHON_MODULE}