#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2012 Hans-Christoph Steiner <hans@eds.org>
# Copyright © 2015 IOhannes m zmölnig <umlaeute@debian.org>
# Description: Main Debian packaging script for pd-chaos
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

LIBRARY_NAME = chaos
PACKAGE = pd-$(LIBRARY_NAME)
pkglibdir = /usr/lib/pd/extra

## use hardening flags
DPKG_EXPORT_BUILDFLAGS = 1
export DEB_BUILD_MAINT_OPTIONS
include /usr/share/dpkg/buildflags.mk


%:
	dh $@ --buildsystem=makefile

override_dh_auto_build:
	dh_auto_build -- \
		CFLAGS="$(CFLAGS) $(CPPFLAGS)" \
		EXTRA_LDFLAGS="$(LDFLAGS)" \
		PDINCLUDE=/usr/include/pd

override_dh_auto_install:
	dh_auto_install -- prefix=/usr pkglibdir=$(pkglibdir)
# replace license file with link to the Debian license file
	rm -f -- $(CURDIR)/debian/$(PACKAGE)/$(pkglibdir)/$(LIBRARY_NAME)/LICENSE.txt

override_dh_shlibdeps:
	find debian -name "*.pd_linux" -exec \
		dpkg-shlibdeps -Tdebian/$(PACKAGE).substvars {} +

override_dh_strip:
	dh_strip
	find debian -name "*.pd_linux" -exec \
		strip --remove-section=.comment --remove-section=.note --strip-unneeded {} +

override_dh_fixperms:
	dh_fixperms
	find debian -name '*.pd_linux' -exec \
		chmod 0644 {} +
