#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS=hardening=+all
DPKG_EXPORT_BUILD_FLAGS=1
include /usr/share/dpkg/buildflags.mk

%:
	dh $@

override_dh_clean:
	dh_clean
	rm -f changelog.txt

override_dh_auto_configure:
	dh_auto_configure -- \
		--enable-pkgdatadir=/usr/lib/aspell \
		--enable-pkglibdir=/usr/lib/aspell/$(DEB_HOST_MULTIARCH) \
		--enable-debian-dict-dir=/usr/lib/aspell \
		--enable-32-bit-hash-fun

override_dh_auto_build:
# Save a pristine copy of original changelog. Since it will be rebuilt
# again later, use -n to preserve the original file instead of
# having it overwritten with autogenerated file. Needed for multiarch
# in case rebuild happens with different makeinfo versions resulting
# in different results.
	lynx -dump -nolist manual/aspell.html/ChangeLog.html > changelog.txt
	dh_auto_build
	make -C manual aspell.html aspell-dev.html

override_dh_install-arch:
	dh_install -a
	install -m644 debian/aspell.compat debian/aspell/usr/share/aspell/
	install -D -m644 debian/aspell.lintian debian/aspell/usr/share/lintian/overrides/aspell
# Empty the dependency_libs lines in the .la files
	sed -i "s,^dependency_libs=.*,dependency_libs=''," \
	   debian/libaspell15/usr/lib/aspell/$(DEB_HOST_MULTIARCH)/*.la
	sed -i "s,^dependency_libs=.*,dependency_libs=''," \
	   debian/libaspell-dev/usr/lib/$(DEB_HOST_MULTIARCH)/*.la \
	   debian/libpspell-dev/usr/lib/$(DEB_HOST_MULTIARCH)/*.la

override_dh_install-indep:
	dh_install --sourcedir=manual -paspell-doc aspell.html usr/share/doc/aspell-doc/
	dh_install --sourcedir=manual -paspell-doc aspell-dev.html usr/share/doc/aspell-doc/
	dh_install -i

override_dh_installdocs:
	dh_installdocs -A changelog.txt

override_dh_makeshlibs:
	dh_makeshlibs -- -V'libaspell15 (>= 0.60.7~20110707)' -Xusr/lib/aspell
