#!/usr/bin/make -f
#export DH_VERBOSE=1

include /usr/share/dpkg/default.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DPKG_GENSYMBOLS_CHECK_LEVEL = 4

%:
	dh $@ --buildsystem=cmake

CMAKE_EXTRA_FLAGS += \
 -DBUILD_SHARED_LIBS:BOOL=ON \

override_dh_auto_configure:
	dh_auto_configure -- $(CMAKE_EXTRA_FLAGS)

override_dh_auto_build-indep:
	(cd docs && doxygen)

override_dh_auto_install-indep:

override_dh_clean-indep:
	dh_clean docs/html/

override_dh_installdocs-arch: manpages
	dh_installdocs

override_dh_clean-arch:
	dh_clean bin/ojph_compress
	dh_clean bin/ojph_expand
	dh_clean bin/openjph.pc
	dh_clean bin/libopenjph.*

debian/ojph_compress.1: debian/ojph_compress.1.in
	LD_PRELOAD= LD_LIBRARY_PATH=./debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH) help2man --version-string=$(DEB_VERSION_UPSTREAM) --help-option=" " --include=$< --output=$@ --no-info --no-discard-stderr ./debian/tmp/usr/bin/ojph_compress

debian/ojph_expand.1: debian/ojph_expand.1.in
	LD_PRELOAD= LD_LIBRARY_PATH=./debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH) help2man --version-string=$(DEB_VERSION_UPSTREAM) --help-option=" " --include=$< --output=$@ --no-info --no-discard-stderr ./debian/tmp/usr/bin/ojph_expand

.PHONY: manpages

manpages: debian/ojph_compress.1 debian/ojph_expand.1
