#!/usr/bin/make -f

export GOCACHE = /tmp/gocache
export GOPATH = ${CURDIR}/_build:/usr/share/gocode
export GO111MODULE := off
export DH_GOLANG_INSTALL_ALL := 1
# GCC 15 defaults to C23, where 'void f()' means 'void f(void)'.  The
# pre-generated cgo C sources shipped by golang-gir-gio-2.0-dev declare the
# cgo exported wrappers with an empty argument list, so they conflict with
# the real prototypes that cgo injects (e.g. _GDesktopAppLaunchCallback_c_wrapper).
# Build the C parts with the C17 dialect, keeping Go's default cgo CFLAGS.
export CGO_CFLAGS := $(CGO_CFLAGS) -O2 -g -std=gnu17
BUILD_DIR := ${CURDIR}/_build/src/github.com/linuxdeepin/go-dbus-factory

%:
	dh $@ --builddirectory=_build --buildsystem=golang --with=golang

execute_after_dh_auto_configure:
	cd ${BUILD_DIR} && make bin && ./gen.sh && \
	find . -type f -name "generator" -delete

	find ${BUILD_DIR} -type f \( -name "README.md" -or -name "CHANGELOG.md" \) -delete
	find ${BUILD_DIR} -type d -name "docs" -exec rm -r {} +

override_dh_installchangelogs:
	dh_installchangelogs -k CHANGELOG.md
