# 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=/opt/hostedtoolcache/Python/3.10.16/x64/bin/python3
LIBEXT=.so

# get the CC and flags used to build python:
GCC = $(shell $(GOCMD) env CC)
CFLAGS = "-I/opt/hostedtoolcache/Python/3.10.16/x64/include/python3.10"
LDFLAGS = "-L/opt/hostedtoolcache/Python/3.10.16/x64/lib" "-lpython3.10" -lcrypt -ldl  -lm -lm

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  client_go$(LIBEXT) -o _client$(LIBEXT) $(CFLAGS) $(LDFLAGS) -fPIC --shared -w
	


