diff --git a/gum/fast/Makefile b/gum/fast/Makefile index 4f872d0..63476e3 100644 --- a/gum/fast/Makefile +++ b/gum/fast/Makefile @@ -1,12 +1,19 @@ -all: fast.c +# Use 'cython2' if present on this system; otherwise fall back to 'cython'. +CYTHON := $(if $(shell command -v cython2 2>/dev/null), cython2, cython) -fast.c: fast.pyx - cython2 fast.pyx +all: fast.so + +fast.so: fast.c gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing \ -I/usr/include/python2.5 -I/usr/include/python2.6 \ -I/usr/include/python2.7 \ - -lcairo -o fast.so fast.c + `pkg-config --cflags cairo` \ + -o fast.so fast.c \ + `pkg-config --libs cairo` if [ ! -e ../fast.so ]; then ln -s fast/fast.so ../; fi +fast.c: fast.pyx + $(CYTHON) fast.pyx + clean: rm -f fast.so fast.c diff --git a/gum/fast/fast.h b/gum/fast/fast.h index 6c5ef6d..54b825f 100644 --- a/gum/fast/fast.h +++ b/gum/fast/fast.h @@ -5,11 +5,3 @@ typedef struct { void *ctx; } PycairoContext; -void cairo_move_to (void *cr, double x, double y); -void cairo_line_to (void *cr, double x, double y); -void cairo_rectangle(void *cr, double x, double ymin, - double w, double h); -void cairo_set_source_rgb (void *cr, double r, double g, double b); -void cairo_stroke (void *cr); -void cairo_fill (void *cr); -void cairo_set_line_width(void *cr, double w); diff --git a/gum/fast/fast.pyx b/gum/fast/fast.pyx index 44b3a67..6bc2d7b 100644 --- a/gum/fast/fast.pyx +++ b/gum/fast/fast.pyx @@ -6,6 +6,8 @@ cdef extern from "math.h": cdef extern from "fast.h": ctypedef struct PycairoContext: void *ctx + +cdef extern from "": void cairo_move_to (void *cr, double x, double y) nogil void cairo_line_to (void *cr, double x, double y) nogil void cairo_rectangle(void *cr, double x, double ymin, diff --git a/gum/fx/Makefile b/gum/fx/Makefile index ec974c2..35fdce1 100644 --- a/gum/fx/Makefile +++ b/gum/fx/Makefile @@ -1,9 +1,16 @@ -all: - cython2 _svf.pyx +# Use 'cython2' if present on this system; otherwise fall back to 'cython'. +CYTHON := $(if $(shell command -v cython2 2>/dev/null), cython2, cython) + +all: _svf.so + +_svf.so: _svf.c gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing \ -I/usr/include/python2.5 -I/usr/include/python2.6 \ -I/usr/include/python2.7 \ -o _svf.so _svf.c +_svf.c: _svf.pyx + $(CYTHON) _svf.pyx + clean: rm -f _svf.so _svf.c