From 6e38768f3da40e0558e90d13c451d10610faadd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D1=80=D0=BE=D0=B4=D0=B8=D0=BD=20=D0=A0=D0=BE?= =?UTF-8?q?=D0=BC=D0=B0=D0=BD?= Date: Mon, 21 Mar 2022 23:48:54 +0300 Subject: [PATCH] =?UTF-8?q?=D1=88=D0=B0=D0=B1=D0=BB=D0=BE=D0=BD=20Makefile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- py/Makefile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 py/Makefile diff --git a/py/Makefile b/py/Makefile new file mode 100644 index 0000000..c8e9ca3 --- /dev/null +++ b/py/Makefile @@ -0,0 +1,33 @@ +# 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 = $(shell python3-config --includes) +LDFLAGS = -L/usr/lib64 $(BOOST_ROOT)/stage/lib/libboost_python*.a -lpthread -ldl -lutil -lm -lm + +all: build + +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-archive -o gorrent_go.a 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.a -o _gorrent$(LIBEXT) $(CFLAGS) $(LDFLAGS) -fPIC --shared -w +