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

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/clone

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


