# Makefile for python interface for package go_goose.
# File is generated by gopy. Do not edit.
# gopy build -output=./py_go_goose -vm=python ./go_goose

GOCMD=go
GOBUILD=$(GOCMD) build -mod=mod
GOIMPORTS=goimports
PYTHON=/data/guangnian/miniconda3/envs/go-goose/bin/python
LIBEXT=.so

# get the CC and flags used to build python:
GCC = $(shell $(GOCMD) env CC)
CFLAGS = -I/data/guangnian/miniconda3/envs/go-goose/include/python3.8
LDFLAGS = -L/data/guangnian/miniconda3/envs/go-goose/lib -lpython3.8 -lcrypt -lpthread -ldl  -lutil -lrt -lm -lm

all: gen build

gen:
	gopy gen -no-make -vm=python ./go_goose

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


