#!/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 targets "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 no longer breaks the
# build. It does three things: include -g, turn off -O3, and turn on
# some debugging stuff in memory allocation.
override_dh_auto_build:
	dh_auto_build -- CHUCK_STRICT=1 linux
	docbook-to-man debian/chuck.sgml > debian/chuck.1

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 '{}' '+'
