aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile19
1 files changed, 18 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 6d39412..e3dd8b8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,17 @@
GPP = gpp
CYTHON = cython
+PKGCONFIG = pkg-config
-all: obj/libcoopgamma_native.c
+PY_MAJOR = 3
+
+OPTIMISE = -O2
+LIBS = python$(PY_MAJOR)
+
+CC_FLAGS = $$($(PKGCONFIG) --cflags $(LIBS)) -std=c99 $(OPTIMISE) -fPIC $(CFLAGS) $(CPPFLAGS)
+LD_FLAGS = $$($(PKGCONFIG) --libs $(LIBS)) -lcoopgamma -std=c99 $(OPTIMISE) -shared $(LDFLAGS)
+
+
+all: bin/libcoopgamma_native.so
obj/libcoopgamma_native.pyx: src/libcoopgamma_native.pyx.gpp
@mkdir -p obj
@@ -10,3 +20,10 @@ obj/libcoopgamma_native.pyx: src/libcoopgamma_native.pyx.gpp
obj/%.c: obj/%.pyx
if ! $(CYTHON) -3 -v $< ; then rm $@ ; false ; fi
+obj/%.o: obj/%.c src/*.h
+ $(CC) $(CC_FLAGS) -iquote"src" -c -o $@ $<
+
+bin/%.so: obj/%.o
+ @mkdir -p bin
+ $(CC) $(LD_FLAGS) -o $@ $^
+