#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export DEB_BUILD_MAINT_OPTIONS = hardening=-all,+format

ifneq (,$(filter $(DEB_HOST_ARCH), amd64 i386))
  CXX_EXCEPTIONS=--enable-cxx-exceptions
endif

%:
	dh $@

binary binary-arch: debian/libunwind-setjmp0.preinst debian/libunwind-setjmp0.postrm

override_dh_auto_build:
	chmod 755 src/ia64/mk_cursor_i
	dh_auto_build

debian/libunwind-setjmp0.%: debian/libunwind-setjmp0.%.in
	$(if $(DEB_HOST_MULTIARCH),:,$(error DEB_HOST_MULTIARCH is not defined))
	sed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' $< > $@

override_dh_auto_configure:
	dh_auto_configure -- --with-pic $(CXX_EXCEPTIONS) --includedir=\$${prefix}/include/$(DEB_HOST_MULTIARCH)

override_dh_install:
	dh_install
	for d in libunwind8 libunwind-dev ; do \
	  find "debian/$$d/usr/lib" -name "libunwind*-setjmp*" -delete ; \
	done
ifeq ($(filter pkg.libunwind.nolzma ,$(DEB_BUILD_PROFILES)),)
ifeq ($(DEB_HOST_ARCH), ia64)	
	mv debian/libunwind-dev/usr/lib/ia64-linux-gnu/libunwind.a debian/libunwind-dev/usr/lib/ia64-linux-gnu/libunwind-real.a
	echo "INPUT( libunwind-real.a liblzma.a )" > debian/libunwind-dev/usr/lib/ia64-linux-gnu/libunwind.a
endif
endif

override_dh_installchangelogs:
	dh_installchangelogs ChangeLog

override_dh_auto_test:
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
	-$(MAKE) check
endif # nocheck

override_dh_strip:
	dh_strip -plibunwind8 -plibunwind-setjmp0 --dbgsym-migration='libunwind8-dbg (<< 1.2.1-1~), libunwind-setjmp0-dbg (<< 1.2.1-1~)'

.PHONY: override_dh_auto_configure override_dh_install override_dh_installchangelogs override_dh_strip

