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

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/synthesis/codon

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 codon.c
	# goimports is needed to ensure that the imports list is valid
	$(GOIMPORTS) -w codon.go
	# generate codon_go$(LIBEXT) from codon.go -- the cgo wrappers to go functions
	$(GOBUILD) -buildmode=c-shared -o codon_go$(LIBEXT) codon.go
	# use pybindgen to build the codon.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 _codon$(LIBEXT) library that contains the cgo and CPython wrappers
	# generated codon.py python wrapper imports this c-code package
	
	$(GCC) codon.c -dynamiclib codon_go$(LIBEXT) -o _codon$(LIBEXT) $(CFLAGS) $(LDFLAGS) -fPIC --shared -w
	


