+# Disable file splitting until pkgsrc gets improved.
+ ${RUN} ${ECHO} "SplitObjs = NO" >> ${WRKSRC:Q}/mk/build.mk
+
+# If there is HsColour is in the PATH, GHC's build system tries to use
+# it without even checking if it really works. That's not what we
+# appreciate.
+ ${RUN} ${ECHO} "HSCOLOUR_SRCS = NO" >> ${WRKSRC:Q}/mk/build.mk
+
+# Don't even think of PDF.
+ ${RUN} ${ECHO} "BUILD_DOCBOOK_PS = NO" >> ${WRKSRC:Q}/mk/build.mk
+ ${RUN} ${ECHO} "BUILD_DOCBOOK_PDF = NO" >> ${WRKSRC:Q}/mk/build.mk
+
+
+# -----------------------------------------------------------------------------
+# Installation/removal hooks
+#
+
+# Substitutions for INSTALL and DEINSTALL that handles package.cache.
+FILES_SUBST+= DISTNAME=${DISTNAME}
+
+# We don't want package.cache to be in the PLIST.
+post-install:
+ ${RM} -f ${DESTDIR:Q}${PREFIX:Q}/lib/${DISTNAME}/package.conf.d/package.cache
+
+
+# -----------------------------------------------------------------------------
+# PLIST
+#
+# We can't use static PLIST because the package installs some files
+# whose names are randomly generated, namely
+# lib/${PKGNAME}/package.conf.d/*.conf
+#
+
+# If we were lucky we could just use "PLIST_TYPE = dynamic", but the
+# feature has seemingly bitrotted.
+.include "../../mk/bsd.prefs.mk"
+.if empty(DESTDIR)
+PKG_FAIL_REASON+="This package can not be built without using DESTDIR.\
+You need to set USE_DESTDIR to \"yes\"."
+.else
+GENERATE_PLIST+= \
+ cd ${DESTDIR:Q}${PREFIX:Q} && \
+ ${FIND} * \( -type f -or -type l \) | ${SORT} -d;
+.endif
+
+
+# -----------------------------------------------------------------------------
+# Sanity checks
+#
+
+# There is an unused script which don't pass the portability test.
+CHECK_PORTABILITY_SKIP+= distrib/prep-bin-dist-mingw
+
+# GHC currently *requires* ${PREFIX}/lib to be in
+# "/etc/ld-elf.so.conf". See
+# http://hackage.haskell.org/trac/ghc/ticket/2933
+CHECK_SHLIBS_SUPPORTED= no
+
+
+# -----------------------------------------------------------------------------
+# Dependencies
+#
+
+# I guess pdcurses works well but not tested.
+USE_NCURSES= yes