#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/hlibrary.mk

DEB_INSTALL_CHANGELOGS_ALL=NEWS

DEB_SETUP_GHC_CONFIGURE_ARGS=-fcurl-pipelining $(if $(wildcard /usr/lib/*/libHSrts_thr.a),,-f-threaded) -flibrary --ghc-options="+RTS -V0 -RTS"

common-binary-post-install-arch::
ifneq (nocheck,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
#	$(DEB_SETUP_BIN_NAME) --builddir=dist-ghc test
	runhaskell Setup.lhs --builddir=dist-ghc test
endif

binary-post-install/darcs::
	dh_bash-completion

# After checking out the debian/ repo, untar the associated upstream
# tarball over the top of it.
P = $(shell dpkg-parsechangelog | sed -rn 's/^Source: //p')
V = $(shell dpkg-parsechangelog | sed -rn 's/^Version: (\d+:)?(.*)-.*/\2/p')
get-orig-source:
	uscan --download-current-version
	tar -C .. --xform 's|^[^/]*|$(notdir $(CURDIR))|' -xf ../$P_$V.orig.tar.gz
