2020-01-18 02:39:01 +01:00
|
|
|
# $NetBSD: haskell.mk,v 1.13 2020/01/18 01:39:01 pho Exp $
|
2014-02-05 08:02:30 +01:00
|
|
|
#
|
|
|
|
# This Makefile fragment handles Haskell Cabal packages.
|
|
|
|
# See: http://www.haskell.org/cabal/
|
|
|
|
#
|
|
|
|
# Note to users:
|
|
|
|
#
|
|
|
|
# * Users choose one favourite Haskell compiler. Though the only
|
|
|
|
# compiler currently supported is GHC.
|
|
|
|
#
|
|
|
|
# * You can't install a cabal package for more than one compilers
|
|
|
|
# simultaneously. In the future, this limitation can possibly be
|
|
|
|
# eliminated using the method used by
|
|
|
|
# "../../lang/python/pyversion.mk".
|
|
|
|
#
|
|
|
|
# Note to package developers:
|
|
|
|
#
|
|
|
|
# * This file must be included *before* "../../mk/bsd.pkg.mk", or
|
|
|
|
# you'll get target-redefinition errors.
|
|
|
|
#
|
|
|
|
# * PKGNAME will automatically be "hs-${DISTNAME}" unless you
|
|
|
|
# explicitly declare it.
|
2019-12-29 17:59:55 +01:00
|
|
|
#
|
2014-02-05 08:02:30 +01:00
|
|
|
# * If your package is on the HackageDB, MASTER_SITES and HOMEPAGE
|
|
|
|
# can be omitted.
|
|
|
|
#
|
|
|
|
# * Package configuration, building, installation, registration and
|
|
|
|
# unregistration are fully automated. You usually don't need to do
|
|
|
|
# anything special.
|
|
|
|
#
|
|
|
|
# * When Haskell libraries depend on other Haskell libraries, they
|
|
|
|
# MUST depend on, not build-depend on, such libraries. So if your
|
|
|
|
# package installs a library, you MUST NOT set
|
|
|
|
# BUILDLINK_DEPMETHOD.${PKG} to "build" in your buildlink3.mk
|
|
|
|
# file. Reason:
|
|
|
|
# 1. Assume we have two libraries A and B, and B build-depends
|
|
|
|
# on A.
|
|
|
|
# 2. We install package A.
|
|
|
|
# 3. We then install package B, which build-depends on A.
|
|
|
|
# 4. After that, a new upstream version of package A is
|
|
|
|
# released. We therefore update package A to the new version.
|
|
|
|
# 5. Package B had a build-dependency on A, so pkgsrc assumes
|
|
|
|
# that it's still safe to use package B without
|
|
|
|
# recompilation of B. But in fact package B requires the
|
|
|
|
# very version of package A which was available when
|
|
|
|
# package B was compiled. So the installed package B is
|
|
|
|
# completely broken at this time.
|
|
|
|
#
|
2020-01-18 02:39:01 +01:00
|
|
|
# Package-settable variables:
|
|
|
|
#
|
|
|
|
# HASKELL_OPTIMIZATION_LEVEL
|
|
|
|
# Description:
|
|
|
|
# Optimization level for compilation.
|
|
|
|
# Possible values:
|
|
|
|
# 0 1 2
|
|
|
|
# Default value:
|
|
|
|
# 2
|
|
|
|
#
|
2014-02-05 08:02:30 +01:00
|
|
|
# User-settable variables:
|
|
|
|
#
|
|
|
|
# HASKELL_COMPILER
|
|
|
|
# Description:
|
|
|
|
# The user's favourite Haskell compiler.
|
|
|
|
# Possible values:
|
|
|
|
# ghc
|
|
|
|
# Default value:
|
|
|
|
# ghc
|
|
|
|
#
|
2014-04-18 15:42:59 +02:00
|
|
|
# HASKELL_ENABLE_SHARED_LIBRARY
|
|
|
|
# Description:
|
|
|
|
# Whether shared library should be built or not.
|
|
|
|
# Possible values:
|
|
|
|
# yes, no
|
|
|
|
# Default value:
|
|
|
|
# yes
|
2014-02-05 08:02:30 +01:00
|
|
|
#
|
|
|
|
# HASKELL_ENABLE_LIBRARY_PROFILING
|
|
|
|
# Description:
|
|
|
|
# Whether profiling library should be built or not.
|
|
|
|
# Possible values:
|
|
|
|
# yes, no
|
|
|
|
# Default value:
|
|
|
|
# yes
|
|
|
|
#
|
|
|
|
# HASKELL_ENABLE_HADDOCK_DOCUMENTATION
|
|
|
|
# Description:
|
|
|
|
# Whether haddock documentation should be built or not.
|
|
|
|
# Possible values:
|
|
|
|
# yes, no
|
|
|
|
# Default value:
|
2014-04-18 15:42:59 +02:00
|
|
|
# yes
|
2014-02-05 08:02:30 +01:00
|
|
|
|
|
|
|
.if !defined(HASKELL_MK)
|
|
|
|
HASKELL_MK= # defined
|
|
|
|
|
|
|
|
.include "../../mk/bsd.fast.prefs.mk"
|
|
|
|
|
|
|
|
|
|
|
|
# Declare HASKELL_COMPILER as one of BUILD_DEFS variables. See
|
|
|
|
# ../../mk/misc/show.mk
|
|
|
|
BUILD_DEFS+= HASKELL_COMPILER
|
2014-04-18 15:42:59 +02:00
|
|
|
BUILD_DEFS+= HASKELL_ENABLE_SHARED_LIBRARY
|
|
|
|
BUILD_DEFS+= HASKELL_ENABLE_LIBRARY_PROFILING
|
|
|
|
BUILD_DEFS+= HASKELL_ENABLE_HADDOCK_DOCUMENTATION
|
2014-02-05 08:02:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Declarations for ../../mk/misc/show.mk
|
|
|
|
_VARGROUPS+= haskell
|
|
|
|
_DEF_VARS.haskell= \
|
2020-01-18 02:39:01 +01:00
|
|
|
HASKELL_OPTIMIZATION_LEVEL \
|
2014-02-05 08:02:30 +01:00
|
|
|
_DISTBASE \
|
|
|
|
_DISTVERSION \
|
|
|
|
_GHC_BIN \
|
|
|
|
_GHC_PKG_BIN \
|
|
|
|
_GHC_VERSION \
|
|
|
|
_GHC_VERSION_CMD \
|
|
|
|
_GHC_VERSION_FULL \
|
|
|
|
_HASKELL_BIN \
|
|
|
|
_HASKELL_PKG_BIN \
|
|
|
|
_HASKELL_PKG_DESCR_FILE \
|
2020-01-09 13:29:32 +01:00
|
|
|
_HASKELL_PKG_ID_FILE \
|
2020-01-01 05:35:29 +01:00
|
|
|
_HASKELL_VERSION
|
2014-04-18 15:42:59 +02:00
|
|
|
_USER_VARS.haskell= \
|
|
|
|
HASKELL_ENABLE_SHARED_LIBRARY \
|
2014-02-05 08:02:30 +01:00
|
|
|
HASKELL_ENABLE_LIBRARY_PROFILING \
|
|
|
|
HASKELL_ENABLE_HADDOCK_DOCUMENTATION
|
|
|
|
|
|
|
|
# PKGNAME is usually named after DISTNAME.
|
|
|
|
PKGNAME?= hs-${DISTNAME}
|
|
|
|
|
|
|
|
# Default value of MASTER_SITES.
|
|
|
|
_DISTBASE?= ${DISTNAME:C/-[^-]*$//}
|
|
|
|
_DISTVERSION?= ${DISTNAME:C/^.*-//}
|
|
|
|
MASTER_SITES?= ${MASTER_SITE_HASKELL_HACKAGE:=${DISTNAME}/}
|
|
|
|
|
|
|
|
# Default value of HOMEPAGE.
|
2019-12-29 17:59:55 +01:00
|
|
|
HOMEPAGE?= http://hackage.haskell.org/package/${_DISTBASE}
|
2014-02-05 08:02:30 +01:00
|
|
|
|
|
|
|
# Cabal packages may use pkg-config, but url2pkg can't detect
|
|
|
|
# that. (PHO: I think that should be handled by url2pkg (2009-05-20))
|
|
|
|
USE_TOOLS+= pkg-config
|
|
|
|
|
2020-01-18 02:39:01 +01:00
|
|
|
# Default value of HASKELL_OPTIMIZATION_LEVEL
|
|
|
|
HASKELL_OPTIMIZATION_LEVEL?= 2
|
|
|
|
|
2014-04-18 15:42:59 +02:00
|
|
|
# Default value of HASKELL_ENABLE_SHARED_LIBRARY
|
|
|
|
HASKELL_ENABLE_SHARED_LIBRARY?= yes
|
|
|
|
|
2014-02-05 08:02:30 +01:00
|
|
|
# Default value of HASKELL_ENABLE_LIBRARY_PROFILING
|
|
|
|
HASKELL_ENABLE_LIBRARY_PROFILING?= yes
|
|
|
|
|
|
|
|
# Default value of HASKELL_ENABLE_HADDOCK_DOCUMENTATION
|
2014-04-18 15:42:59 +02:00
|
|
|
HASKELL_ENABLE_HADDOCK_DOCUMENTATION?= yes
|
2014-02-05 08:02:30 +01:00
|
|
|
|
|
|
|
# Compiler specific variables and targets.
|
|
|
|
.if ${HASKELL_COMPILER} == "ghc"
|
|
|
|
|
2020-01-09 13:29:32 +01:00
|
|
|
# Add dependency on GHC.
|
2020-01-11 08:47:18 +01:00
|
|
|
.include "../../lang/ghc88/buildlink3.mk"
|
2014-02-05 08:02:30 +01:00
|
|
|
|
|
|
|
# Tools
|
|
|
|
_GHC_BIN= ${BUILDLINK_PREFIX.ghc}/bin/ghc
|
|
|
|
_GHC_PKG_BIN= ${BUILDLINK_PREFIX.ghc}/bin/ghc-pkg
|
|
|
|
_HASKELL_BIN= ${_GHC_BIN} # Expose to the outer scope.
|
|
|
|
_HASKELL_PKG_BIN= ${_GHC_PKG_BIN} # Expose to the outer scope.
|
|
|
|
|
|
|
|
# Determine GHC version.
|
2020-01-01 05:54:10 +01:00
|
|
|
_GHC_VERSION_CMD= ${_GHC_BIN} -V 2>/dev/null | ${CUT} -d ' ' -f 8
|
2020-01-01 05:35:29 +01:00
|
|
|
_GHC_VERSION= ${_GHC_VERSION_CMD:sh}
|
2014-02-05 08:02:30 +01:00
|
|
|
_GHC_VERSION_FULL= ghc-${_GHC_VERSION}
|
|
|
|
_HASKELL_VERSION= ${_GHC_VERSION_FULL} # Expose to the outer scope.
|
|
|
|
|
2014-04-18 15:42:59 +02:00
|
|
|
# Determine GHC shlib suffix
|
2019-12-29 17:59:55 +01:00
|
|
|
_GHC_SHLIB_SUFFIX.dylib= dylib
|
2014-04-18 15:42:59 +02:00
|
|
|
_GHC_SHLIB_SUFFIX= ${_GHC_SHLIB_SUFFIX.${SHLIB_TYPE}:Uso}
|
|
|
|
_HASKELL_SHLIB_SUFFIX= ${_GHC_SHLIB_SUFFIX}
|
|
|
|
|
2014-02-05 08:02:30 +01:00
|
|
|
# GHC requires C compiler.
|
|
|
|
USE_LANGUAGES+= c
|
|
|
|
|
|
|
|
# Declarations for ../../mk/configure/configure.mk
|
|
|
|
CONFIGURE_ARGS+= --ghc
|
2019-12-29 17:59:55 +01:00
|
|
|
CONFIGURE_ARGS+= --with-compiler=${_GHC_BIN:Q}
|
|
|
|
CONFIGURE_ARGS+= --with-hc-pkg=${_GHC_PKG_BIN:Q}
|
|
|
|
CONFIGURE_ARGS+= --prefix=${PREFIX:Q}
|
2014-02-05 08:02:30 +01:00
|
|
|
.endif # ${HASKELL_COMPILER}
|
|
|
|
|
2014-04-18 15:42:59 +02:00
|
|
|
# Shared libraries
|
|
|
|
.if ${HASKELL_ENABLE_SHARED_LIBRARY} == "yes"
|
|
|
|
CONFIGURE_ARGS+= --enable-shared --enable-executable-dynamic
|
2020-01-02 17:45:15 +01:00
|
|
|
.else
|
|
|
|
CONFIGURE_ARGS+= --disable-shared --disable-executable-dynamic
|
2014-04-18 15:42:59 +02:00
|
|
|
.endif
|
|
|
|
|
2014-02-05 08:02:30 +01:00
|
|
|
# Library profiling
|
|
|
|
.if ${HASKELL_ENABLE_LIBRARY_PROFILING} == "yes"
|
2020-01-02 17:45:15 +01:00
|
|
|
CONFIGURE_ARGS+= --enable-library-profiling
|
|
|
|
.else
|
|
|
|
CONFIGURE_ARGS+= --disable-library-profiling
|
2014-02-05 08:02:30 +01:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# Haddock documentations
|
|
|
|
.if ${HASKELL_ENABLE_HADDOCK_DOCUMENTATION} == "yes"
|
2019-12-29 17:59:55 +01:00
|
|
|
CONFIGURE_ARGS+= --with-haddock=${BUILDLINK_PREFIX.ghc:Q}/bin/haddock
|
2014-02-05 08:02:30 +01:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# Optimization
|
2020-01-18 02:39:01 +01:00
|
|
|
CONFIGURE_ARGS+= -O${HASKELL_OPTIMIZATION_LEVEL}
|
|
|
|
|
|
|
|
# Parallelization: the definition of this variable is exactly the same
|
|
|
|
# as that of _MAKE_JOBS in mk/build/build.mk, but since it's an
|
|
|
|
# internal variable we don't want to reuse it here.
|
|
|
|
.if defined(MAKE_JOBS_SAFE) && !empty(MAKE_JOBS_SAFE:M[nN][oO])
|
|
|
|
_HASKELL_BUILD_JOBS= # nothing
|
|
|
|
.elif defined(MAKE_JOBS.${PKGPATH})
|
|
|
|
_HASKELL_BUILD_JOBS= -j${MAKE_JOBS.${PKGPATH}}
|
|
|
|
.elif defined(MAKE_JOBS)
|
|
|
|
_HASKELL_BUILD_JOBS= -j${MAKE_JOBS}
|
|
|
|
.endif
|
2014-02-05 08:02:30 +01:00
|
|
|
|
2019-12-29 17:59:55 +01:00
|
|
|
# Starting from GHC 7.10 (or 7.8?), packages are installed in
|
|
|
|
# directories with a hashed name so we can no longer predict the
|
|
|
|
# contents of PLIST.
|
|
|
|
GENERATE_PLIST+= \
|
|
|
|
cd ${DESTDIR:Q}${PREFIX:Q} && \
|
|
|
|
${FIND} * \( -type f -o -type l \) | ${SORT};
|
|
|
|
# But since our packages may still have PLIST files, it is necessary
|
|
|
|
# to ignore them until we get rid of them all. Or they all will be
|
|
|
|
# broken.
|
|
|
|
PLIST_SRC= # none
|
|
|
|
.if ${PKG_DEVELOPER:Uno:tl} != "no"
|
|
|
|
.PHONY: _check-ignored-plist
|
|
|
|
privileged-install-hook: _check-ignored-plist
|
|
|
|
_check-ignored-plist: error-check
|
|
|
|
${RUN}if ${TEST} -f PLIST; then \
|
|
|
|
${DELAYED_WARNING_MSG} "[haskell.mk] The PLIST file is no longer used. Please remove it."; \
|
|
|
|
fi
|
|
|
|
.endif
|
2014-02-05 08:02:30 +01:00
|
|
|
|
|
|
|
# We might not have any working Haskell interpreter so compile
|
2019-12-31 08:16:25 +01:00
|
|
|
# Setup.?hs to a binary. Since dynamic linkage is much faster, we try
|
|
|
|
# it and then fall back to static linkage if that didn't work.
|
2014-02-05 08:02:30 +01:00
|
|
|
pre-configure: ${WRKSRC}/Setup
|
|
|
|
|
|
|
|
${WRKSRC}/Setup:
|
2019-12-31 08:16:25 +01:00
|
|
|
${RUN}cd ${WRKSRC} && \
|
|
|
|
( ${_HASKELL_BIN:Q} --make Setup -dynamic || \
|
|
|
|
${_HASKELL_BIN:Q} --make Setup -static )
|
2014-02-05 08:02:30 +01:00
|
|
|
|
|
|
|
# Define configure target.
|
|
|
|
do-configure:
|
2019-12-31 08:16:25 +01:00
|
|
|
${RUN}cd ${WRKSRC:Q} && \
|
2014-02-05 08:02:30 +01:00
|
|
|
${SETENV} ${CONFIGURE_ENV} \
|
2020-01-02 17:34:47 +01:00
|
|
|
./Setup configure ${PKG_VERBOSE:D-v} ${CONFIGURE_ARGS}
|
2014-02-05 08:02:30 +01:00
|
|
|
|
|
|
|
# Define build target.
|
|
|
|
do-build:
|
2019-12-31 08:16:25 +01:00
|
|
|
${RUN}cd ${WRKSRC:Q} && \
|
2020-01-18 02:39:01 +01:00
|
|
|
./Setup build ${PKG_VERBOSE:D-v} ${_HASKELL_BUILD_JOBS}
|
2014-02-05 08:02:30 +01:00
|
|
|
.if ${HASKELL_ENABLE_HADDOCK_DOCUMENTATION} == "yes"
|
2019-12-31 08:16:25 +01:00
|
|
|
${RUN}cd ${WRKSRC:Q} && \
|
2020-01-02 17:34:47 +01:00
|
|
|
./Setup haddock ${PKG_VERBOSE:D-v}
|
2014-02-05 08:02:30 +01:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# Define install target. We need installed-pkg-config to be installed
|
|
|
|
# for package registration (if any).
|
2019-12-29 17:59:55 +01:00
|
|
|
_HASKELL_PKG_DESCR_DIR= ${PREFIX}/lib/${DISTNAME}/${_HASKELL_VERSION}
|
|
|
|
_HASKELL_PKG_DESCR_FILE= ${_HASKELL_PKG_DESCR_DIR}/package-description
|
2020-01-09 13:29:32 +01:00
|
|
|
_HASKELL_PKG_ID_FILE= ${_HASKELL_PKG_DESCR_DIR}/package-id
|
2014-02-05 08:02:30 +01:00
|
|
|
|
2019-12-29 17:59:55 +01:00
|
|
|
INSTALLATION_DIRS+= ${_HASKELL_PKG_DESCR_DIR}
|
2014-02-05 08:02:30 +01:00
|
|
|
do-install:
|
2019-12-31 08:16:25 +01:00
|
|
|
${RUN}cd ${WRKSRC} && \
|
2020-01-09 13:29:32 +01:00
|
|
|
./Setup register ${PKG_VERBOSE:D-v} \
|
|
|
|
--gen-pkg-config=dist/package-description \
|
|
|
|
--print-ipid \
|
|
|
|
> dist/package-id && \
|
2020-01-02 17:34:47 +01:00
|
|
|
./Setup copy ${PKG_VERBOSE:D-v} --destdir=${DESTDIR:Q} && \
|
2016-04-10 17:58:02 +02:00
|
|
|
if [ -f dist/package-description ]; then \
|
2020-01-09 13:29:32 +01:00
|
|
|
${INSTALL_DATA} dist/package-description \
|
|
|
|
${DESTDIR:Q}${_HASKELL_PKG_DESCR_FILE:Q}; \
|
|
|
|
${INSTALL_DATA} dist/package-id \
|
|
|
|
${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q}; \
|
|
|
|
fi
|
2014-02-05 08:02:30 +01:00
|
|
|
|
|
|
|
# Define test target.
|
|
|
|
do-test:
|
2019-12-31 08:16:25 +01:00
|
|
|
${RUN}cd ${WRKSRC} && \
|
2020-01-02 17:34:47 +01:00
|
|
|
./Setup test ${PKG_VERBOSE:D-v}
|
2014-02-05 08:02:30 +01:00
|
|
|
|
|
|
|
# Substitutions for INSTALL and DEINSTALL.
|
|
|
|
FILES_SUBST+= HASKELL_PKG_BIN=${_HASKELL_PKG_BIN}
|
|
|
|
FILES_SUBST+= HASKELL_PKG_DESCR_FILE=${_HASKELL_PKG_DESCR_FILE}
|
2020-01-09 13:29:32 +01:00
|
|
|
FILES_SUBST+= HASKELL_PKG_ID_FILE=${_HASKELL_PKG_ID_FILE}
|
2014-02-05 08:02:30 +01:00
|
|
|
|
|
|
|
INSTALL_TEMPLATES+= ../../mk/haskell/INSTALL.in
|
|
|
|
DEINSTALL_TEMPLATES+= ../../mk/haskell/DEINSTALL.in
|
|
|
|
|
|
|
|
.endif # HASKELL_MK
|