#!/usr/bin/make -f

export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

export ORG_GRADLE_PROJECT_skipAndroid=true
export ORG_GRADLE_PROJECT_errorProne=false
export DEB_HOST_GNU_CPU ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
export DEB_HOST_GNU_SYSTEM ?= $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)
export DEB_TARGET_GNU_CPU ?= $(shell dpkg-architecture -qDEB_TARGET_GNU_CPU)
export DEB_TARGET_GNU_SYSTEM ?= $(shell dpkg-architecture -qDEB_TARGET_GNU_SYSTEM)

export ORG_GRADLE_PROJECT_protoc="/usr/bin/protoc"

# Ensure packages build with no Internet access
export http_proxy=127.0.0.1:9
export https_proxy=127.0.0.1:9

%:
	dh $@ --buildsystem=gradle --with maven_repo_helper

override_dh_auto_configure:
	dh_auto_configure --buildsystem=autoconf
	dh_auto_configure

override_dh_auto_build:
	dh_auto_build --buildsystem=autoconf
	dh_auto_build

override_dh_auto_install:
	dh_auto_install --buildsystem=autoconf
	dh_auto_install

override_dh_installexamples:
	dh_installexamples
	rm -f debian/libgrpc-java/usr/share/doc/libgrpc-java/examples/android/helloworld/.gitignore
	rm -f debian/libgrpc-java/usr/share/doc/libgrpc-java/examples/android/routeguide/.gitignore
	rm -f debian/libgrpc-java/usr/share/doc/libgrpc-java/examples/android/routeguide/app/.gitignore

override_dh_auto_test:

override_dh_link:
	dh_link
	jdupes -rl debian/libgrpc-java/usr
