#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/rules/autoreconf.mk

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_MULTIARCH = $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

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

DEB_DH_INSTALL_SOURCEDIR   := debian/tmp
DEB_INSTALL_CHANGELOGS_ALL := ChangeLog.html
DEB_CONFIGURE_EXTRA_FLAGS  := --enable-pkgdatadir=/usr/share/aspell \
	                      --enable-pkglibdir=/usr/lib/aspell/$(DEB_HOST_MULTIARCH) \
			      --enable-debian-dict-dir=/usr/lib/aspell \
			      --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
	                      --enable-32-bit-hash-fun

# 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.
makebuilddir::
	cp -n manual/aspell.html/ChangeLog.html .

build/aspell-doc::
	make -C manual aspell.html aspell-dev.html

install/aspell::
	install -m644 debian/aspell.compat debian/aspell/usr/share/aspell/
	install -D -m644 debian/aspell.lintian debian/aspell/usr/share/lintian/overrides/aspell

install/aspell-doc::
	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/

binary-install/libaspell15::
# 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

binary-install/libaspell-dev::
binary-install/libpspell-dev::
	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

clean::
	rm -f ChangeLog.html
