#!/usr/bin/make -f

#export DH_VERBOSE = 1

export DH_GOLANG_INSTALL_ALL := 1

# gcc-15 起 C 默认标准变为 C23，函数声明 `void f()` 被解释为 `void f(void)`，
# 与 cgo 导出头中的完整原型冲突；go-gir(gio-2.0) 预生成的 C 代码使用这种旧式
# 声明，导致 cgo 编译失败。dh-golang 由 dpkg-buildflags 的 CFLAGS 生成
# CGO_CFLAGS，因此通过 DEB_CFLAGS_MAINT_APPEND 为 cgo 的 C 代码追加
# -std=gnu17，使其保持 C17 语义。
export DEB_CFLAGS_MAINT_APPEND := $(DEB_CFLAGS_MAINT_APPEND) -std=gnu17

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

execute_before_dh_auto_configure:
	cd gettext; ./build_test_locale_data

execute_after_dh_auto_install:
	find $(CURDIR)/debian/golang-dlib-dev -regex '.*\.git\|.*testdata\|.*LICENSE\|.*\.gitignore' | xargs rm -rf
