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

## 内嵌 Tcl/Tk 为上世纪 90 年代 C 代码（旧式无原型声明，如 "extern double strtod();"），
## 在 gcc-15 默认 -std=gnu23 下编译失败（f() 被当作 f(void)，与 libc 原型冲突）。
## 通过 dpkg-buildflags 追加 -std=gnu90，恢复到 C90 方言编译（参数优先修复，不动上游源码）。
export DEB_CFLAGS_APPEND := $(DEB_CFLAGS_APPEND) -std=gnu90

%:
	dh $@ --no-parallel

override_dh_missing:
	dh_missing --list-missing

override_dh_install:
	## change permissions of sound files
	find $(CURDIR)/res -name "*.wav" | while read a; do chmod -x $$a; done
	chmod +x $(CURDIR)/res/sounds/player
	## rename files and install Changes as upstream changelog
	cp $(CURDIR)/Micropolis $(CURDIR)/micropolis
	cp $(CURDIR)/src/notes/Changes $(CURDIR)/Changelog
	## install all files
	dh_install
	## remove arch-dependent files and embedded fonts
	rm -f $(CURDIR)/debian/micropolis-data/usr/share/games/micropolis/res/dejavu-lgc/*
	rm -f $(CURDIR)/debian/micropolis-data/usr/share/games/micropolis/res/sim
