# Makefile for python interface for package slow5.
# File is generated by gopy. Do not edit.
# gopy build -output=poly/io/slow5 -vm=python3 github.com/bebop/poly/io/slow5

GOCMD=go
GOBUILD=$(GOCMD) build -mod=mod
GOIMPORTS=goimports
PYTHON=/opt/homebrew/bin/python3
LIBEXT=.so

# get the CC and flags used to build python:
GCC = $(shell $(GOCMD) env CC)
CFLAGS = "-I/opt/homebrew/opt/python@3.13/Frameworks/Python.framework/Versions/3.13/include/python3.13"
LDFLAGS = "-L/opt/homebrew/opt/python@3.13/Frameworks/Python.framework/Versions/3.13/lib" "-lpython3.13" -ldl  -framework CoreFoundation 

all: gen build

gen:
	gopy gen -no-make -vm=python3 github.com/bebop/poly/io/slow5

build:
	# build target builds the generated files -- this is what gopy build does..
	# this will otherwise be built during go build and may be out of date
	- rm slow5.c
	# goimports is needed to ensure that the imports list is valid
	$(GOIMPORTS) -w slow5.go
	# generate slow5_go$(LIBEXT) from slow5.go -- the cgo wrappers to go functions
	$(GOBUILD) -buildmode=c-shared -o slow5_go$(LIBEXT) slow5.go
	# use pybindgen to build the slow5.c file which are the CPython wrappers to cgo wrappers..
	# note: pip install pybindgen to get pybindgen if this fails
	$(PYTHON) build.py
	# build the _slow5$(LIBEXT) library that contains the cgo and CPython wrappers
	# generated slow5.py python wrapper imports this c-code package
	
	$(GCC) slow5.c -dynamiclib slow5_go$(LIBEXT) -o _slow5$(LIBEXT) $(CFLAGS) $(LDFLAGS) -fPIC --shared -w
	


