#!/usr/bin/make -f
# Work around #481592 (Closes: #485631).  Remove when #481592 closes!
CFLAGS := $(filter-out -g,$(CFLAGS))

%:
	+dh --with bash-completion $@
override_dh_auto_build: Setup
	./Setup build
override_dh_auto_clean: Setup
	./Setup clean
override_dh_auto_configure: Setup
	./Setup configure --prefix=/usr -fcurl-pipelining --constraint=parsec\<3 $(if $(wildcard /usr/lib/*/libHSrts_thr.a),,-f-threaded) -f-library --ghc-options="+RTS -V0 -RTS"
override_dh_auto_install: Setup
	./Setup copy --destdir=$(CURDIR)/debian/darcs
override_dh_auto_test: Setup
ifneq (nocheck,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	./Setup test
endif
Setup:
	ghc --make Setup
override_dh_installchangelogs:	# http://bugs.debian.org/589368
	dh_installchangelogs -- NEWS

# 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
