#!/usr/bin/make -f

export PYBUILD_NAME=grpcio

export GRPC_PYTHON_BUILD_WITH_CYTHON=True
export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=True
export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=True
export GRPC_PYTHON_BUILD_SYSTEM_CARES=True

NPROC := $(shell nproc)
export PARALLEL=$(NPROC)

# Get version from changelog as well as lsb_release
# to compute unique build version (useful for repo mirroring systems doing file pooling)
PKG_VERSION  := $(shell dpkg-parsechangelog | grep -E '^Version:' | cut -d' ' -f2)
DIST_NAME    := $(shell lsb_release -si)
DIST_RELEASE := $(shell lsb_release -sc)
DIST_VERSION := $(shell lsb_release -sr)
PKG_VERSION_TAG := $(PKG_VERSION)+$(DIST_NAME).$(DIST_VERSION).$(DIST_RELEASE)

%:
	dh $@ --with python3 --buildsystem=pybuild

override_dh_auto_clean:
	dh_auto_clean  
	rm -rfv src/python/grpcio/grpcio.egg-info/
	rm -fv a.out
	rm -fv src/python/grpcio/grpc/_grpcio_metadata.py

override_dh_auto_build:
	dh_auto_build

override_dh_gencontrol:
	dh_gencontrol -- -v"$(PKG_VERSION_TAG)"
