#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all


CPPCFLAGS=$(CFLAGS) -fPIC $(CPPFLAGS)


# main packaging script based on dh7 syntax
%:
	dh $@ 

# dh_make generated override targets
# This is example for Cmake (See https://bugs.debian.org/641051 )
#override_dh_auto_configure:
#	dh_auto_configure -- \
#	-DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

override_dh_auto_build:
	dh_auto_build -Daudio -- CFLAGS="$(CPPCFLAGS)" LDFLAGS="$(LDFLAGS)"
	dh_auto_build -Dutils -- CFLAGS="$(CPPCFLAGS)" LDFLAGS="$(LDFLAGS) -Wl,--export-dynamic -shared -fPIC"
override_dh_auto_clean:
	dh_auto_clean -Daudio
	dh_auto_clean -Dutils
override_dh_auto_install:
	dh_auto_install -Daudio -- pkglibdir=/usr/lib/pd/extra
	dh_auto_install -Dutils -- pkglibdir=/usr/lib/pd/extra
	find "$(CURDIR)/debian/pd-nusmuk" -name LICENSE.txt -delete
override_dh_shlibdeps:
	find "$(CURDIR)/debian/pd-nusmuk" -name "*.pd_linux" -exec dpkg-shlibdeps -Tdebian/pd-nusmuk.substvars {} +
	dh_shlibdeps

test:
	@echo "CFLAGS: $(CPPCFLAGS)"
	@echo "LDFLAGS: $(LDFLAGS)"
	@echo "CURDIR: $(CURDIR)"
