Changeset View
Standalone View
Mk/Uses/cabal.mk
- This file was added.
# $FreeBSD$ | |||||
# | |||||
tcberner: ^ can you please run the `/usr/ports/Tools/scripts/indent_make_if.pl` on this file? -- this… | |||||
# Provide support for building Haskell packages using Cabal. | |||||
# | |||||
# Feature: cabal | |||||
# Usage: USES=cabal | |||||
# | |||||
# Variables, which can be set by the port: | |||||
# | |||||
# USE_CABAL List of Haskell packages required to build a port. | |||||
# Should be listed along with version, like profunctors-5.3 | |||||
# Package revision can be specified too with | |||||
Done Inline ActionsYou should check if cabal_ARGS is empty and set IGNORE= when it is like other USES to prevent someone from adding bogus USES=cabal:foobar things. tobik: You should check if `cabal_ARGS` is empty and set `IGNORE=` when it is like other USES to… | |||||
# usual "_" syntax: invariant-0.5.1_1 | |||||
# When creating a new port, the initial list can be built | |||||
# using make-use-cabal auxiliary target. | |||||
# | |||||
# CABAL_FLAGS List of Cabal flags to be passed verbatim into --flags | |||||
# argument of cabal-install utility. Used for both | |||||
# cabal configure and cabal build. | |||||
# | |||||
# EXECUTABLES List of executable Cabal targets to be built and installed. | |||||
# default: ${PORTNAME} | |||||
# | |||||
# opt_USE_CABAL Variant of USE_CABAL to be used with options framework. | |||||
# opt_CABAL_FLAGS Variant of CABAL_FLAGS to be used with options framework. | |||||
# Note that it works a bit differently from CABAL_FLAGS: | |||||
# it appends "${opt_CABAL_FLAGS}" when the option is enabled | |||||
# and "-${opt_CABAL_FLAGS}" otherwise. | |||||
# opt_EXECUTABLES Variant of EXECUTABLES to be used with options framework. | |||||
# | |||||
# MAINTAINER: haskell@FreeBSD.org | |||||
Done Inline ActionsShould we specify both http and https? 0mp: Should we specify both http and https? | |||||
Done Inline ActionsYes, probably. Should https: be listed first? arrowd: Yes, probably. Should `https:` be listed first? | |||||
Done Inline Actionshttps first? For example see make -V MASTER_SITE_EPEL7. 0mp: https first?
For example see ` make -V MASTER_SITE_EPEL7`. | |||||
Done Inline ActionsRemove :DEFAULT, it is the default :-) mat: Remove `:DEFAULT`, it is the default :-) | |||||
.if !defined(_INCLUDE_USES_CABAL_MK) | |||||
_INCLUDE_USES_CABAL_MK= yes | |||||
Done Inline ActionsWhat happens if DISTFILES is changed, will EXTRACT_ONLY contain something that exists? mat: What happens if `DISTFILES` is changed, will `EXTRACT_ONLY` contain something that exists? | |||||
Done Inline ActionsProbably not. I'm not even sure about ?=. Should I turn it into DISTFILES=? arrowd: Probably not. I'm not even sure about `?=`. Should I turn it into `DISTFILES=`? | |||||
Done Inline ActionsIs there any cabal port that actually sets DISTFILES ? mat: Is there any cabal port that actually sets DISTFILES ? | |||||
.if !empty(cabal_ARGS) | |||||
Done Inline ActionsNo, no, no, no, no, no, no, never, you are not in a port's Makefile, you are in the framework. If you have things you need to be done later, you use the PRE/POST mechanism. See any USES that checks for _POSTMKINCLUDED. (perl5, localbase, to cite a few.) mat: No, no, no, no, no, no, no, never, you are not in a port's Makefile, you are in the framework. | |||||
Done Inline ActionsThis is not right, see Mk/bsd.port.mk lines 5186+ to see what to add to that variable. mat: This is not right, see Mk/bsd.port.mk lines 5186+ to see what to add to that variable. | |||||
Done Inline ActionsI saw that, but don't get what's wrong with this line. Should I prepend some integer before the target name? arrowd: I saw that, but don't get what's wrong with this line. Should I prepend some integer before the… | |||||
IGNORE= Incorrect 'USES= cabal:${cabal_ARGS}' cabal takes no arguments | |||||
.endif | |||||
EXECUTABLES?= ${PORTNAME} | |||||
CABAL_HOME= ${WRKDIR}/cabal-home | |||||
. if !defined(CABAL_BOOTSTRAP) | |||||
BUILD_DEPENDS+= cabal:devel/hs-cabal-install \ | |||||
ghc:lang/ghc | |||||
. endif | |||||
# Inherited via lang/ghc we need to depend on iconv and libgmp.so (stage q/a) | |||||
iconv_ARGS= translit | |||||
.include "${USESDIR}/iconv.mk" | |||||
LIB_DEPENDS+= libgmp.so:math/gmp \ | |||||
libffi.so.6:devel/libffi | |||||
DIST_SUBDIR?= cabal | |||||
MASTER_SITES?= https://hackage.haskell.org/package/${PORTNAME}-${PORTVERSION}/ \ | |||||
http://hackage.haskell.org/package/${PORTNAME}-${PORTVERSION}/ | |||||
DISTFILES= ${PORTNAME}-${PORTVERSION}${EXTRACT_SUFX} | |||||
EXTRACT_ONLY= ${PORTNAME}-${PORTVERSION}${EXTRACT_SUFX} | |||||
Done Inline ActionsThose should probably be helpers added to bsd.options.mk. mat: Those should probably be helpers added to bsd.options.mk. | |||||
Done Inline ActionsDespite being specific to Cabal build system only? arrowd: Despite being specific to Cabal build system only? | |||||
Done Inline ActionsThere are helpers that are for qmake, cmake, meson, they are all in bsd.options.mk. I would prefer that all helpers be defined in one place, instead of having some magically happen when you add a feature. mat: There are helpers that are for qmake, cmake, meson, they are all in bsd.options.mk.
I would… | |||||
_USES_extract= 701:cabal-post-extract | |||||
_USES_stage= 751:cabal-post-install-script | |||||
BUILD_TARGET?= ${EXECUTABLES:S/^/exe:&/} | |||||
_use_cabal= ${USE_CABAL:O:u} | |||||
. for package in ${_use_cabal} | |||||
_PKG_GROUP= ${package:C/[\.-]//g} | |||||
_PKG_WITHOUT_REV= ${package:C/_[0-9]+//} | |||||
_REV= ${package:C/[^_]*//:S/_//} | |||||
MASTER_SITES+= https://hackage.haskell.org/package/:${package:C/[\.-]//g} \ | |||||
http://hackage.haskell.org/package/:${package:C/[\.-]//g} | |||||
DISTFILES+= ${package:C/_[0-9]+//}/${package:C/_[0-9]+//}${EXTRACT_SUFX}:${package:C/[\.-]//g} | |||||
. if !defined(CABAL_BOOTSTRAP) | |||||
EXTRACT_ONLY+= ${package:C/_[0-9]+//}/${package:C/_[0-9]+//}${EXTRACT_SUFX} | |||||
. endif | |||||
. if ${package:C/[^_]*//:S/_//} != "" | |||||
DISTFILES+= ${package:C/_[0-9]+//}/revision/${package:C/[^_]*//:S/_//}.cabal:${package:C/[\.-]//g} | |||||
. endif | |||||
. endfor | |||||
# Fetches and unpacks package source from Hackage using only PORTNAME and PORTVERSION. | |||||
Done Inline Actionscabal-extract: ${WRKDIR} mat: ```
cabal-extract: ${WRKDIR}
``` | |||||
cabal-extract: ${WRKDIR} | |||||
${SETENV} HOME=${CABAL_HOME} cabal new-update | |||||
cd ${WRKDIR} && \ | |||||
${SETENV} HOME=${CABAL_HOME} cabal get ${PORTNAME}-${PORTVERSION} | |||||
# Fetches and unpacks dependencies sources for a cabal-extract'ed package. | |||||
# Builds them as side-effect. | |||||
cabal-extract-deps: | |||||
cd ${WRKSRC} && \ | |||||
${SETENV} HOME=${CABAL_HOME} cabal new-configure --flags="${CABAL_FLAGS}" ${CONFIGURE_ARGS} | |||||
cd ${WRKSRC} && \ | |||||
${SETENV} HOME=${CABAL_HOME} cabal new-build --dependencies-only | |||||
# Generates USE_CABAL= ... line ready to be pasted into the port based on artifacts of cabal-extract-deps. | |||||
make-use-cabal: | |||||
Done Inline ActionsIt might be good to pass through MAKE_ENV too. This is important for stuff like BINARY_ALIAS etc. to work correctly. Ports might want to overwrite do-build, so maybe guard it with .if !target(do-build). Same for do-install. tobik: It might be good to pass through MAKE_ENV too. This is important for stuff like BINARY_ALIAS… | |||||
@echo ==================== | |||||
Done Inline ActionsUseless use of xargs: find ... -exec basename {} + mat: Useless use of xargs:
```
find ... -exec basename {} +
``` | |||||
@find ${CABAL_HOME} -name '*.conf' -exec basename {} + | sed -E 's|-[0-9a-z]{64}\.conf||' | sort | xargs echo -n USE_CABAL= && echo | |||||
# Checks USE_CABAL items that have revisions. | |||||
check-revs: | |||||
Done Inline ActionsRemove trailing / mat: Remove trailing / | |||||
. for package in ${_use_cabal} | |||||
@(fetch -o /dev/null http://hackage.haskell.org/package/${package:C/_[0-9]+//}/revision/1.cabal 2>/dev/null && echo "Package ${package} has revisions") || true | |||||
@([ -d ${DISTDIR}/${DIST_SUBDIR}/${package:C/_[0-9]+//}/revision ] && echo " hint: " `find ${DISTDIR}/${DIST_SUBDIR}/${package:C/_[0-9]+//} -name *.cabal | xargs basename`) || true | |||||
. endfor | |||||
. if !defined(CABAL_BOOTSTRAP) | |||||
Done Inline ActionsYou should not overwrite post-extract, in case a port needs it, create your own and add it to _USES_extract. See Mk/bsd.port.mk lines 5186+ to see what to add to that variable. mat: You should not overwrite //post-extract//, in case a port needs it, create your own and add it… | |||||
cabal-post-extract: | |||||
. for package in ${_use_cabal} | |||||
. if ${package:C/[^_]*//:S/_//} != "" | |||||
cp ${DISTDIR}/${DIST_SUBDIR}/${package:C/_[0-9]+//}/revision/${package:C/[^_]*//:S/_//}.cabal `find ${WRKDIR}/${package:C/_[0-9]+//} -name *.cabal -depth 1` | |||||
Done Inline ActionsPlease remove this, we already have a standard way for ports to "do" things when they need, do not invent a new one mat: Please remove this, we already have a standard way for ports to "do" things when they need, do… | |||||
. endif | |||||
cd ${WRKDIR} && \ | |||||
mv ${package:C/_[0-9]+//} ${WRKSRC}/ | |||||
Done Inline ActionsPlease do not piggy-back on an existing target, create your own. mat: Please do not piggy-back on an existing target, create your own. | |||||
. endfor | |||||
mkdir -p ${CABAL_HOME}/.cabal | |||||
touch ${CABAL_HOME}/.cabal/config | |||||
. if !target(do-build) | |||||
do-build: | |||||
cd ${WRKSRC} && \ | |||||
${SETENV} ${MAKE_ENV} HOME=${CABAL_HOME} cabal new-build --offline --flags "${CABAL_FLAGS}" ${BUILD_ARGS} ${BUILD_TARGET} | |||||
. endif | |||||
. if !target(do-install) | |||||
Done Inline Actions$(xxx), not with the backticks. mat: `$(xxx)`, not with the backticks. | |||||
do-install: | |||||
. for exe in ${EXECUTABLES} | |||||
${INSTALL_PROGRAM} \ | |||||
$$(find ${WRKSRC}/dist-newstyle -name ${exe} -type f -perm +111) \ | |||||
${STAGEDIR}${PREFIX}/bin | |||||
. endfor | |||||
. endif | |||||
. if !defined(SKIP_CABAL_PLIST) | |||||
cabal-post-install-script: | |||||
. for exe in ${EXECUTABLES} | |||||
${ECHO_CMD} 'bin/${exe}' >> ${TMPPLIST} | |||||
Done Inline ActionsI think ports should define their own post-install target(s) and have these done in their Makefile. mat: I think ports should define their own `post-install` target(s) and have these done in their… | |||||
. endfor | |||||
. endif | |||||
Done Inline ActionsNever overwrite an existing target name, create your own. mat: Never overwrite an existing target name, create your own. | |||||
Done Inline ActionsPut the .if !defined(SKIP_CABAL_PLIST) around the target, no need to create an empty target. mat: Put the `.if !defined(SKIP_CABAL_PLIST)` around the target, no need to create an empty target. | |||||
. endif # !defined(CABAL_BOOTSTRAP) | |||||
.endif |
^ can you please run the /usr/ports/Tools/scripts/indent_make_if.pl on this file? -- this makes the nested if and for statements a bit easier to read