2015-07-06 23:40:11 +02:00
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
# Handle Erlang related ports
|
|
|
|
#
|
|
|
|
# Feature: erlang
|
|
|
|
# Usage: USES=erlang
|
2015-07-08 01:06:33 +02:00
|
|
|
# Valid ARGS: rebar, rebar3, or no argument (custom build)
|
2015-07-06 23:40:11 +02:00
|
|
|
#
|
|
|
|
# Additional variables:
|
|
|
|
#
|
|
|
|
# ERL_APP_NAME - Erlang app name as installed in Erlang's lib dir (minus version)
|
|
|
|
# ERL_APP_ROOT - Root directory for this Erlang app
|
|
|
|
# REBAR_CMD - Path to the "rebar" command
|
|
|
|
# REBAR3_CMD - Path to the "rebar3" command
|
|
|
|
# REBAR_PROFILE - Rebar profile
|
|
|
|
# REBAR_TARGETS - Rebar target list (usually compile, maybe escriptize)
|
|
|
|
# ERL_BUILD_NAME - Build name for rebar3
|
|
|
|
# ERL_BUILD_DEPS - List of BUILD_DEPENDS in category/portname format
|
|
|
|
# ERL_RUN_DEPS - List of RUN_DEPENDS in category/portname format
|
|
|
|
# ERL_DOCS - List of documentation files and directories
|
|
|
|
#
|
|
|
|
# MAINTAINER: olgeni@FreeBSD.org
|
|
|
|
|
|
|
|
.if !defined(_INCLUDE_USES_ERLANG_MK)
|
|
|
|
_INCLUDE_USES_ERLANG_MK=yes
|
|
|
|
|
|
|
|
ERL_APP_NAME?= ${PORTNAME}
|
|
|
|
ERL_APP_ROOT?= ${PREFIX}/lib/erlang/lib/${ERL_APP_NAME}-${PORTVERSION}
|
|
|
|
REBAR_CMD= ${LOCALBASE}/bin/rebar
|
|
|
|
REBAR3_CMD= ${LOCALBASE}/bin/rebar3
|
|
|
|
REBAR_PROFILE?= default
|
|
|
|
REBAR_TARGETS?= compile
|
|
|
|
ERL_BUILD_NAME?= default
|
|
|
|
ERL_BUILD_DEPS?=
|
|
|
|
ERL_RUN_DEPS?=
|
|
|
|
ERL_DOCS?= README*
|
|
|
|
|
|
|
|
# VERSION is used in every Erlang pkg-plist
|
|
|
|
PLIST_SUB+= VERSION="${PORTVERSION}"
|
|
|
|
|
2015-10-15 09:36:38 +02:00
|
|
|
BUILD_DEPENDS+= erl:${PORTSDIR}/lang/erlang
|
|
|
|
RUN_DEPENDS+= erl:${PORTSDIR}/lang/erlang
|
2015-07-06 23:40:11 +02:00
|
|
|
|
|
|
|
.if ${erlang_ARGS:Mrebar}
|
2015-10-15 09:36:38 +02:00
|
|
|
BUILD_DEPENDS+= rebar>=0:${PORTSDIR}/devel/rebar
|
2015-07-06 23:40:11 +02:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if ${erlang_ARGS:Mrebar3}
|
2015-10-15 09:36:38 +02:00
|
|
|
BUILD_DEPENDS+= rebar3>=0:${PORTSDIR}/devel/rebar3
|
2015-07-06 23:40:11 +02:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.for depend in ${ERL_BUILD_DEPS}
|
2015-10-15 09:36:38 +02:00
|
|
|
BUILD_DEPENDS+= ${depend:T}>=0:${PORTSDIR}/${depend}
|
2015-07-06 23:40:11 +02:00
|
|
|
.endfor
|
|
|
|
|
|
|
|
.for depend in ${ERL_RUN_DEPS}
|
2015-10-15 09:36:38 +02:00
|
|
|
RUN_DEPENDS+= ${depend:T}>=0:${PORTSDIR}/${depend}
|
2015-07-06 23:40:11 +02:00
|
|
|
.endfor
|
|
|
|
|
|
|
|
.if ${erlang_ARGS:Mrebar}
|
|
|
|
ERLANG_COMPILE= ${REBAR_CMD}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if ${erlang_ARGS:Mrebar3}
|
2015-09-09 00:12:22 +02:00
|
|
|
ERLANG_COMPILE= HOME=${WRKDIR} ${REBAR3_CMD}
|
2015-07-06 23:40:11 +02:00
|
|
|
.endif
|
|
|
|
|
Rewrite the target ordering code.
The targets now have priority assigned to them, and, when the dependency
ordering magic is done at the end of bsd.port.mk, they are sorted
according to their priority.
This allows USES to add targets easily and have them run whenever they
want without touching bsd.port.mk.
To add a target that runs just before post-configure run, do:
_USES_configure+= 695:my-post-configure
my-post-configure:
do something
To fine tune when the target is ran, look at the values in the *_SEQ
variables at the end of bsd.port.mk, and the other USES.
Allow ports Makefiles to override the priority of targets with the
TARGET_ORDER_OVERRIDE variable. For example, to get post-install
running earlier, (its default is 700) do:
TARGET_ORDER_OVERRIDE= 650:post-install
While there, add options target helpers for the do-* targets when they
exist.
Reviewed by: antoine, bapt
Exp-run by: antoine
Sponsored by: Absolight
Differential Revision: https://reviews.freebsd.org/D3099
2015-08-17 15:31:25 +02:00
|
|
|
_USES_patch+= 650:post-patch-erlang
|
2015-07-06 23:40:11 +02:00
|
|
|
post-patch-erlang:
|
|
|
|
@${FIND} ${WRKSRC} -name .gitignore -delete
|
2015-07-14 12:44:50 +02:00
|
|
|
# Attempt to remove all traces of {vsn, ....}; replace with actual PORTVERSION
|
2015-07-06 23:40:11 +02:00
|
|
|
@if [ -f ${WRKSRC}/src/${ERL_APP_NAME}.app.src ]; then \
|
2015-07-14 12:44:50 +02:00
|
|
|
${REINPLACE_CMD} -i '' -e 's/{ *vsn,.*}/{vsn, "${PORTVERSION}"}/' \
|
2015-07-06 23:40:11 +02:00
|
|
|
${WRKSRC}/src/${ERL_APP_NAME}.app.src; \
|
|
|
|
fi
|
|
|
|
@if [ -f ${WRKSRC}/ebin/${ERL_APP_NAME}.app ]; then \
|
2015-07-14 12:44:50 +02:00
|
|
|
${REINPLACE_CMD} -i '' -e 's/{ *vsn,.*}/{vsn, "${PORTVERSION}"}/' \
|
2015-07-06 23:40:11 +02:00
|
|
|
${WRKSRC}/ebin/${ERL_APP_NAME}.app; \
|
|
|
|
fi
|
|
|
|
@${GREP} -l "%%LOCALBASE%%" $$(${FIND} ${WRKSRC}) \
|
|
|
|
| ${XARGS} ${REINPLACE_CMD} -i '' -e "s@%%LOCALBASE%%@${LOCALBASE}@"
|
2015-07-14 12:44:50 +02:00
|
|
|
@${GREP} -l "%%PORTVERSION%%" $$(${FIND} ${WRKSRC}) \
|
|
|
|
| ${XARGS} ${REINPLACE_CMD} -i '' -e "s@%%PORTVERSION%%@${PORTVERSION}@"
|
2015-07-06 23:40:11 +02:00
|
|
|
# Always try to build with the system version of rebar and rebar3
|
|
|
|
@if [ -f ${WRKSRC}/rebar.config ]; then \
|
2015-07-21 17:56:34 +02:00
|
|
|
${REINPLACE_CMD} -i '' -e "s@\./rebar3@${REBAR3_CMD}@; s@\./rebar@${REBAR_CMD}@" \
|
2015-07-06 23:40:11 +02:00
|
|
|
${WRKSRC}/rebar.config; \
|
|
|
|
fi
|
|
|
|
@${RM} -f ${WRKSRC}/src/*.orig ${WRKSRC}/include/*.orig
|
|
|
|
|
Rewrite the target ordering code.
The targets now have priority assigned to them, and, when the dependency
ordering magic is done at the end of bsd.port.mk, they are sorted
according to their priority.
This allows USES to add targets easily and have them run whenever they
want without touching bsd.port.mk.
To add a target that runs just before post-configure run, do:
_USES_configure+= 695:my-post-configure
my-post-configure:
do something
To fine tune when the target is ran, look at the values in the *_SEQ
variables at the end of bsd.port.mk, and the other USES.
Allow ports Makefiles to override the priority of targets with the
TARGET_ORDER_OVERRIDE variable. For example, to get post-install
running earlier, (its default is 700) do:
TARGET_ORDER_OVERRIDE= 650:post-install
While there, add options target helpers for the do-* targets when they
exist.
Reviewed by: antoine, bapt
Exp-run by: antoine
Sponsored by: Absolight
Differential Revision: https://reviews.freebsd.org/D3099
2015-08-17 15:31:25 +02:00
|
|
|
.if !target(do-build)
|
|
|
|
do-build:
|
2015-07-06 23:40:11 +02:00
|
|
|
# This will cause calls to local rebar and rebar3 to fail; makes it easier to spot them
|
|
|
|
@${RM} -f ${WRKSRC}/rebar ${WRKSRC}/rebar3
|
|
|
|
.for target in ${REBAR_TARGETS}
|
|
|
|
# Remove rebar.lock every time - it can be created again after each run of rebar3
|
|
|
|
@${RM} ${WRKSRC}/rebar.lock
|
|
|
|
@cd ${WRKSRC} && REBAR_PROFILE=${REBAR_PROFILE} ${ERLANG_COMPILE} ${target}
|
|
|
|
.endfor
|
Rewrite the target ordering code.
The targets now have priority assigned to them, and, when the dependency
ordering magic is done at the end of bsd.port.mk, they are sorted
according to their priority.
This allows USES to add targets easily and have them run whenever they
want without touching bsd.port.mk.
To add a target that runs just before post-configure run, do:
_USES_configure+= 695:my-post-configure
my-post-configure:
do something
To fine tune when the target is ran, look at the values in the *_SEQ
variables at the end of bsd.port.mk, and the other USES.
Allow ports Makefiles to override the priority of targets with the
TARGET_ORDER_OVERRIDE variable. For example, to get post-install
running earlier, (its default is 700) do:
TARGET_ORDER_OVERRIDE= 650:post-install
While there, add options target helpers for the do-* targets when they
exist.
Reviewed by: antoine, bapt
Exp-run by: antoine
Sponsored by: Absolight
Differential Revision: https://reviews.freebsd.org/D3099
2015-08-17 15:31:25 +02:00
|
|
|
.endif # !target(do-build)
|
2015-07-06 23:40:11 +02:00
|
|
|
|
Rewrite the target ordering code.
The targets now have priority assigned to them, and, when the dependency
ordering magic is done at the end of bsd.port.mk, they are sorted
according to their priority.
This allows USES to add targets easily and have them run whenever they
want without touching bsd.port.mk.
To add a target that runs just before post-configure run, do:
_USES_configure+= 695:my-post-configure
my-post-configure:
do something
To fine tune when the target is ran, look at the values in the *_SEQ
variables at the end of bsd.port.mk, and the other USES.
Allow ports Makefiles to override the priority of targets with the
TARGET_ORDER_OVERRIDE variable. For example, to get post-install
running earlier, (its default is 700) do:
TARGET_ORDER_OVERRIDE= 650:post-install
While there, add options target helpers for the do-* targets when they
exist.
Reviewed by: antoine, bapt
Exp-run by: antoine
Sponsored by: Absolight
Differential Revision: https://reviews.freebsd.org/D3099
2015-08-17 15:31:25 +02:00
|
|
|
.if !target(do-install)
|
|
|
|
do-install:
|
2015-07-06 23:40:11 +02:00
|
|
|
@${MKDIR} ${STAGEDIR}${ERL_APP_ROOT}
|
|
|
|
@${MKDIR} ${STAGEDIR}${ERL_APP_ROOT}/src
|
|
|
|
cd ${WRKSRC}/src && ${COPYTREE_SHARE} \* ${STAGEDIR}${ERL_APP_ROOT}/src
|
|
|
|
@${MKDIR} ${STAGEDIR}${ERL_APP_ROOT}/ebin
|
|
|
|
.if ${erlang_ARGS:Mrebar3}
|
|
|
|
${INSTALL_DATA} ${WRKSRC}/_build/${ERL_BUILD_NAME}/lib/${ERL_APP_NAME}/ebin/* \
|
|
|
|
${STAGEDIR}${ERL_APP_ROOT}/ebin
|
|
|
|
.else
|
|
|
|
${INSTALL_DATA} ${WRKSRC}/ebin/* ${STAGEDIR}${ERL_APP_ROOT}/ebin
|
|
|
|
.endif
|
|
|
|
if [ -d ${WRKSRC}/include ]; then \
|
|
|
|
${MKDIR} ${STAGEDIR}${ERL_APP_ROOT}/include; \
|
|
|
|
cd ${WRKSRC}/include && ${COPYTREE_SHARE} \* ${STAGEDIR}${ERL_APP_ROOT}/include; \
|
|
|
|
fi
|
|
|
|
if [ -d ${WRKSRC}/priv ]; then \
|
|
|
|
${MKDIR} ${STAGEDIR}${ERL_APP_ROOT}/priv; \
|
|
|
|
cd ${WRKSRC}/priv && ${COPYTREE_SHARE} \* ${STAGEDIR}${ERL_APP_ROOT}/priv; \
|
|
|
|
fi
|
|
|
|
.if ${ERL_DOCS} != ""
|
|
|
|
@${MKDIR} ${STAGEDIR}${DOCSDIR}
|
|
|
|
.for file in ${ERL_DOCS}
|
2015-07-10 12:10:09 +02:00
|
|
|
if [ -d "${WRKSRC}/${file}" ]; then \
|
2015-07-10 13:31:40 +02:00
|
|
|
cd ${WRKSRC} && ${COPYTREE_SHARE} ${file} ${STAGEDIR}${DOCSDIR}; \
|
2015-07-06 23:40:11 +02:00
|
|
|
else \
|
|
|
|
${INSTALL_DATA} ${WRKSRC}/${file} ${STAGEDIR}${DOCSDIR}; \
|
|
|
|
fi
|
|
|
|
.endfor
|
|
|
|
.endif # .if ${ERL_DOCS} != ""
|
|
|
|
.if ${REBAR_TARGETS:Mescriptize}
|
|
|
|
@${MKDIR} ${STAGEDIR}${PREFIX}/bin
|
|
|
|
${INSTALL_SCRIPT} ${WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/bin
|
|
|
|
.endif
|
Rewrite the target ordering code.
The targets now have priority assigned to them, and, when the dependency
ordering magic is done at the end of bsd.port.mk, they are sorted
according to their priority.
This allows USES to add targets easily and have them run whenever they
want without touching bsd.port.mk.
To add a target that runs just before post-configure run, do:
_USES_configure+= 695:my-post-configure
my-post-configure:
do something
To fine tune when the target is ran, look at the values in the *_SEQ
variables at the end of bsd.port.mk, and the other USES.
Allow ports Makefiles to override the priority of targets with the
TARGET_ORDER_OVERRIDE variable. For example, to get post-install
running earlier, (its default is 700) do:
TARGET_ORDER_OVERRIDE= 650:post-install
While there, add options target helpers for the do-* targets when they
exist.
Reviewed by: antoine, bapt
Exp-run by: antoine
Sponsored by: Absolight
Differential Revision: https://reviews.freebsd.org/D3099
2015-08-17 15:31:25 +02:00
|
|
|
.endif # !target(do-install)
|
2015-07-06 23:40:11 +02:00
|
|
|
|
|
|
|
.endif #!defined(_INCLUDE_USES_ERLANG_MK)
|