#!/usr/bin/make -f
export DH_VERBOSE = 1

export PYBUILD_NAME=eduvpn-common
PYWRAPPER_PATH := wrappers/python
DEB_VERSION := $(shell dpkg-parsechangelog --show-field=Version | cut -d '+' -f1 | cut -d '-' -f1)


override_dh_auto_install:
	dh_auto_install --sourcedirectory $(PYWRAPPER_PATH)

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


override_dh_auto_test:


override_dh_auto_clean:
	dh_auto_clean --sourcedirectory $(PYWRAPPER_PATH)

	GOCACHE="/tmp" go clean

	rm -rf debian/libeduvpn_common.so.$(DEB_VERSION)
	rm -rf debian/libeduvpn_common-$(DEB_VERSION).h

override_dh_auto_configure:
	dh_auto_configure --sourcedirectory $(PYWRAPPER_PATH)

override_dh_auto_build:
	dh_auto_build --sourcedirectory $(PYWRAPPER_PATH)

	# Make go library
	GOCACHE="/tmp" CGO_ENABLED="1" go build -ldflags='-extldflags "-Wl,-soname,libeduvpn_common.so.1"' -o debian/libeduvpn_common.so.$(DEB_VERSION) -buildmode=c-shared ./exports
	


override_dh_builddeb:
	dh_builddeb -- -Zxz


override_dh_link:
	dh_link usr/lib/libeduvpn_common.so.$(DEB_VERSION) usr/lib/libeduvpn_common.so.1
