# Makefile for python interface for package client.
# File is generated by gopy. Do not edit.
# gopy build -output=tinfoil_verifier -vm=python3 github.com/tinfoilsh/verifier/client

GOCMD=go
GOBUILD=$(GOCMD) build -mod=mod
GOIMPORTS=goimports
PYTHON=/Users/runner/hostedtoolcache/Python/3.12.9/arm64/bin/python3
LIBEXT=.so

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

all: gen build

gen:
	gopy gen -no-make -vm=python3 github.com/tinfoilsh/verifier/client

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


