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

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

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


