#!/usr/bin/make -f

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

export CFLAGS:=$(CPPFLAGS) $(CFLAGS)

%:
	dh $@ --sourcedirectory=src

# The build target "linux" generates a single chuck executable with
# support for multiple sound systems: alsa, pulse, and jack.
#
# CHUCK_STRICT=1 just turns on -Wall.
#
# Can add CHUCK_DEBUG=y here if desired. It does three things:
#  - include -g
#  - do not include -O3
#  - enable memory allocation debugging support
override_dh_auto_build: debian/chuck.1
	dh_auto_build -- CHUCK_STRICT=1 linux

debian/chuck.1: debian/chuck.sgml
	docbook-to-man $< > $@

override_dh_installchangelogs:
	dh_installchangelogs VERSIONS

execute_after_dh_installexamples:
	@echo "Symbolic link duplicate audio files."
	-jdupes --recurse --link-soft $(CURDIR)/debian/chuck-data/usr/share/doc/chuck-data/examples

override_dh_compress:
	dh_compress -X.wav -X.ck

execute_after_dh_fixperms:
	-find $(CURDIR)/debian/chuck-data/usr/share/doc/chuck-data/examples/ -type f -exec chmod --changes 644 '{}' '+'
