# Makefile for python interface for package smr.
# File is generated by gopy. Do not edit.
# gopy gen -build-tags=-gcflags=all="-N -l" -output=../distributed_notebook/smr -vm=/home/scusemua/virtual-envs/venv/bin/python3.12 github.com/scusemua/distributed-notebook/smr

GOCMD=go
GOBUILD=$(GOCMD) build -mod=mod
GOIMPORTS=goimports
PYTHON=/home/scusemua/virtual-envs/venv/bin/python3.12
LIBEXT=.so

# get the CC and flags used to build python:
GCC = $(shell $(GOCMD) env CC)
CFLAGS = "-I/usr/local/include/python3.12d"
LDFLAGS = "-L/usr/local/lib" "-lpython3.12d" -ldl -lm

all: gen build

gen:
	gopy gen -no-make -build-tags=-gcflags=all="-N -l" -vm=/home/scusemua/virtual-envs/venv/bin/python3.12 github.com/scusemua/distributed-notebook/smr

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


