#!/usr/bin/make -f

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

DEB_SETUP_GHC_CONFIGURE_ARGS = --datasubdir=gtk2hs-buildtools

# Build with -O0 on ppc64el to work-around a GHC bug
# see https://bugs.debian.org/942585
# and https://gitlab.haskell.org/ghc/ghc/issues/17203
ifneq (,$(filter $(DEB_BUILD_ARCH),ppc64el ppc64))
	DEB_SETUP_GHC_CONFIGURE_ARGS += --ghc-options="-O0"
endif

build/gtk2hs-buildtools:: build-ghc-stamp

install/gtk2hs-buildtools::
	$(DEB_SETUP_BIN_NAME) copy --builddir=dist-ghc \
		--destdir=debian/gtk2hs-buildtools/
	rm -rf debian/gtk2hs-buildtools/usr/lib/haskell-packages
	rm -rf debian/gtk2hs-buildtools/usr/lib/ghc-doc
	rm -rf debian/gtk2hs-buildtools/usr/share/doc/*ghc*
