gorrent/py/gorrent/Makefile

39 lines
1.3 KiB
Makefile

# Makefile for python interface for package gorrent.
# File is generated by gopy. Do not edit.
# gopy gen --output=py/gorrent gorrent
GOCMD=go
GOBUILD=$(GOCMD) build -mod=mod
GOIMPORTS=goimports
PYTHON=/usr/bin/python
LIBEXT=.so
# get the CC and flags used to build python:
GCC = $(shell $(GOCMD) env CC)
CFLAGS = -I/usr/include/python3.9
LDFLAGS = -L/usr/lib64 -lpython3.9 -lpthread -ldl -lutil -lm -lm
all: gen build
gen:
gopy gen -no-make -gorrent
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 gorrent.c
# goimports is needed to ensure that the imports list is valid
$(GOIMPORTS) -w gorrent.go
# generate gorrent_go$(LIBEXT) from gorrent.go -- the cgo wrappers to go functions
$(GOBUILD) -buildmode=c-shared -o gorrent_go$(LIBEXT) gorrent.go
# use pybindgen to build the gorrent.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 _gorrent$(LIBEXT) library that contains the cgo and CPython wrappers
# generated gorrent.py python wrapper imports this c-code package
$(GCC) gorrent.c gorrent_go$(LIBEXT) -o _gorrent$(LIBEXT) $(CFLAGS) $(LDFLAGS) -fPIC --shared -w