#!/usr/bin/make -f

export DH_VERBOSE = 1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# See ENVIRONMENT in dpkg-buildflags(1).
# Package maintainers to append CFLAGS.
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# Package maintainers to append LDFLAGS.
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

%:
	dh $@ --buildsystem=cmake

override_dh_auto_configure:
	dh_auto_configure -- \
	-DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) \
	-DCMAKE_INSTALL_LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH) \
	-DCMAKE_PREFIX_PATH=/usr/include/agg2

override_dh_auto_install:
	dh_auto_install
	find $(CURDIR)/debian/tmp -name '*.a' | xargs rm -f
	mkdir -p $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/gr
	find $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH) -name '*plugin.so' | xargs -I% mv % $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/gr
	mkdir -p $(CURDIR)/debian/tmp/usr/share/doc/gr-framework-doc/
	mv $(CURDIR)/debian/tmp/usr/share/doc/grplot/* $(CURDIR)/debian/tmp/usr/share/doc/gr-framework-doc/
	mv $(CURDIR)/debian/tmp/usr/share/doc/GR/* $(CURDIR)/debian/tmp/usr/share/doc/gr-framework-doc/
