#!/usr/bin/make -f

DEB_SETUP_BIN_NAME = debian/hlibrary.setup
DEB_CABAL_PACKAGE = ghc-lib-parser
DEB_DEFAULT_COMPILER = ghc

DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
ifneq (,$(filter $(DEB_BUILD_ARCH),arm64 armhf armel i386 s390x x32))
       DEB_SETUP_GHC_CONFIGURE_ARGS += --ghc-options="-O0 -optc--param -optcggc-min-expand=10"
endif

# Compilation fails on non-threaded RTS, see https://bugs.debian.org/1020900.
ifeq (0,$(shell ghc --info | grep 'Unregisterised.*YES' >/dev/null 2>&1; echo $$?))
	DEB_SETUP_GHC_CONFIGURE_ARGS += --ghc-options="-optc-UTHREADED_RTS" --gcc-options="-UTHREADED_RTS"
endif

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