#!/usr/bin/make -f

# resolve if release is experimental
EXP_RELEASE = $(filter experimental% UNRELEASED,\
 $(shell dpkg-parsechangelog -S Distribution))

# relax symbols check when targeting experimental
export DPKG_GENSYMBOLS_CHECK_LEVEL=$(if $(EXP_RELEASE),0,1)

%:
	dh $@ --sourcedirectory=libmarpa_dist --builddirectory=build --with pkgkde_symbolshelper

# put aside upstream-shipped autogenerated files during build
CRUFT_COPY = libmarpa_dist/LIB_VERSION
execute_before_dh_auto_configure:
	$(foreach file,$(wildcard $(CRUFT_COPY)),\
		cp --force --no-target-directory -- $(file) $(file).save)
execute_after_dh_auto_clean:
	$(foreach file,$(wildcard $(CRUFT_COPY:%=%.save)),\
		mv --force --no-target-directory -- $(file:%.save=%) $(file))

# drop obsolete libtool linker files before debhelper notices and complains
execute_before_dh_install:
	find debian/tmp -name '*.la' -print -delete

# Let d-shlibs calculate development package dependencies
#  and handle shared library install
execute_after_dh_install:
	dh_install
	d-shlibmove --commit \
		--devunversioned \
		--exclude-la \
		--multiarch \
		--movedev "debian/tmp/usr/include/*" usr/include/ \
		debian/tmp/usr/lib/*/*.so
