Changeset View
Changeset View
Standalone View
Standalone View
Mk/Uses/erlang.mk
Show All 33 Lines | |||||
ERL_DOCS?= README* | ERL_DOCS?= README* | ||||
# VERSION is used in every Erlang pkg-plist | # VERSION is used in every Erlang pkg-plist | ||||
PLIST_SUB+= VERSION="${PORTVERSION}" | PLIST_SUB+= VERSION="${PORTVERSION}" | ||||
BUILD_DEPENDS+= erl:lang/erlang | BUILD_DEPENDS+= erl:lang/erlang | ||||
RUN_DEPENDS+= erl:lang/erlang | RUN_DEPENDS+= erl:lang/erlang | ||||
.if ${erlang_ARGS:Mrebar} | . if ${erlang_ARGS:Mrebar} | ||||
BUILD_DEPENDS+= rebar>=0:devel/rebar | BUILD_DEPENDS+= rebar>=0:devel/rebar | ||||
.endif | . endif | ||||
.if ${erlang_ARGS:Mrebar3} | . if ${erlang_ARGS:Mrebar3} | ||||
BUILD_DEPENDS+= rebar3>=0:devel/rebar3 | BUILD_DEPENDS+= rebar3>=0:devel/rebar3 | ||||
.endif | . endif | ||||
.for depend in ${ERL_BUILD_DEPS} | . for depend in ${ERL_BUILD_DEPS} | ||||
BUILD_DEPENDS+= ${depend:T}>=0:${depend} | BUILD_DEPENDS+= ${depend:T}>=0:${depend} | ||||
.endfor | . endfor | ||||
.for depend in ${ERL_RUN_DEPS} | . for depend in ${ERL_RUN_DEPS} | ||||
RUN_DEPENDS+= ${depend:T}>=0:${depend} | RUN_DEPENDS+= ${depend:T}>=0:${depend} | ||||
.endfor | . endfor | ||||
.if ${erlang_ARGS:Mrebar} | . if ${erlang_ARGS:Mrebar} | ||||
ERLANG_COMPILE= ${REBAR_CMD} | ERLANG_COMPILE= ${REBAR_CMD} | ||||
.endif | . endif | ||||
.if ${erlang_ARGS:Mrebar3} | . if ${erlang_ARGS:Mrebar3} | ||||
ERLANG_COMPILE= HOME=${WRKDIR} ${REBAR3_CMD} | ERLANG_COMPILE= HOME=${WRKDIR} ${REBAR3_CMD} | ||||
.endif | . endif | ||||
_USES_patch+= 650:post-patch-erlang | _USES_patch+= 650:post-patch-erlang | ||||
post-patch-erlang: | post-patch-erlang: | ||||
@${FIND} ${WRKSRC} -name .gitignore -delete | @${FIND} ${WRKSRC} -name .gitignore -delete | ||||
# Attempt to remove all traces of {vsn, ....}; replace with actual PORTVERSION | # Attempt to remove all traces of {vsn, ....}; replace with actual PORTVERSION | ||||
@if [ -f ${WRKSRC}/src/${ERL_APP_NAME}.app.src ]; then \ | @if [ -f ${WRKSRC}/src/${ERL_APP_NAME}.app.src ]; then \ | ||||
${REINPLACE_CMD} -i '' -e 's/{ *vsn,.*}/{vsn, "${PORTVERSION}"}/' \ | ${REINPLACE_CMD} -i '' -e 's/{ *vsn,.*}/{vsn, "${PORTVERSION}"}/' \ | ||||
${WRKSRC}/src/${ERL_APP_NAME}.app.src; \ | ${WRKSRC}/src/${ERL_APP_NAME}.app.src; \ | ||||
fi | fi | ||||
@if [ -f ${WRKSRC}/ebin/${ERL_APP_NAME}.app ]; then \ | @if [ -f ${WRKSRC}/ebin/${ERL_APP_NAME}.app ]; then \ | ||||
${REINPLACE_CMD} -i '' -e 's/{ *vsn,.*}/{vsn, "${PORTVERSION}"}/' \ | ${REINPLACE_CMD} -i '' -e 's/{ *vsn,.*}/{vsn, "${PORTVERSION}"}/' \ | ||||
${WRKSRC}/ebin/${ERL_APP_NAME}.app; \ | ${WRKSRC}/ebin/${ERL_APP_NAME}.app; \ | ||||
fi | fi | ||||
@${GREP} -l "%%LOCALBASE%%" $$(${FIND} ${WRKSRC} -type f) \ | @${GREP} -l "%%LOCALBASE%%" $$(${FIND} ${WRKSRC} -type f) \ | ||||
| ${XARGS} ${REINPLACE_CMD} -i '' -e "s@%%LOCALBASE%%@${LOCALBASE}@" | | ${XARGS} ${REINPLACE_CMD} -i '' -e "s@%%LOCALBASE%%@${LOCALBASE}@" | ||||
@${GREP} -l "%%PORTVERSION%%" $$(${FIND} ${WRKSRC} -type f) \ | @${GREP} -l "%%PORTVERSION%%" $$(${FIND} ${WRKSRC} -type f) \ | ||||
| ${XARGS} ${REINPLACE_CMD} -i '' -e "s@%%PORTVERSION%%@${PORTVERSION}@" | | ${XARGS} ${REINPLACE_CMD} -i '' -e "s@%%PORTVERSION%%@${PORTVERSION}@" | ||||
# Always try to build with the system version of rebar and rebar3 | # Always try to build with the system version of rebar and rebar3 | ||||
@if [ -f ${WRKSRC}/rebar.config ]; then \ | @if [ -f ${WRKSRC}/rebar.config ]; then \ | ||||
${REINPLACE_CMD} -i '' -e "s@\./rebar3@${REBAR3_CMD}@; s@\./rebar@${REBAR_CMD}@" \ | ${REINPLACE_CMD} -i '' -e "s@\./rebar3@${REBAR3_CMD}@; s@\./rebar@${REBAR_CMD}@" \ | ||||
${WRKSRC}/rebar.config; \ | ${WRKSRC}/rebar.config; \ | ||||
fi | fi | ||||
@${RM} ${WRKSRC}/src/*.orig ${WRKSRC}/include/*.orig | @${RM} ${WRKSRC}/src/*.orig ${WRKSRC}/include/*.orig | ||||
.if !target(do-build) | . if !target(do-build) | ||||
do-build: | do-build: | ||||
# This will cause calls to local rebar and rebar3 to fail; makes it easier to spot them | # This will cause calls to local rebar and rebar3 to fail; makes it easier to spot them | ||||
@${RM} ${WRKSRC}/rebar ${WRKSRC}/rebar3 | @${RM} ${WRKSRC}/rebar ${WRKSRC}/rebar3 | ||||
.for target in ${REBAR_TARGETS} | . for target in ${REBAR_TARGETS} | ||||
# Remove rebar.lock every time - it can be created again after each run of rebar3 | # Remove rebar.lock every time - it can be created again after each run of rebar3 | ||||
@${RM} ${WRKSRC}/rebar.lock | @${RM} ${WRKSRC}/rebar.lock | ||||
@cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} REBAR_PROFILE=${REBAR_PROFILE} ${ERLANG_COMPILE} ${target} | @cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} REBAR_PROFILE=${REBAR_PROFILE} ${ERLANG_COMPILE} ${target} | ||||
.endfor | . endfor | ||||
.endif # !target(do-build) | . endif # !target(do-build) | ||||
.if !target(do-install) | . if !target(do-install) | ||||
do-install: | do-install: | ||||
@${MKDIR} ${STAGEDIR}${ERL_APP_ROOT} | @${MKDIR} ${STAGEDIR}${ERL_APP_ROOT} | ||||
@${MKDIR} ${STAGEDIR}${ERL_APP_ROOT}/src | @${MKDIR} ${STAGEDIR}${ERL_APP_ROOT}/src | ||||
cd ${WRKSRC}/src && ${COPYTREE_SHARE} \* ${STAGEDIR}${ERL_APP_ROOT}/src | cd ${WRKSRC}/src && ${COPYTREE_SHARE} \* ${STAGEDIR}${ERL_APP_ROOT}/src | ||||
@${MKDIR} ${STAGEDIR}${ERL_APP_ROOT}/ebin | @${MKDIR} ${STAGEDIR}${ERL_APP_ROOT}/ebin | ||||
.if ${erlang_ARGS:Mrebar3} | . if ${erlang_ARGS:Mrebar3} | ||||
${INSTALL_DATA} ${WRKSRC}/_build/${ERL_BUILD_NAME}/lib/${ERL_APP_NAME}/ebin/* \ | ${INSTALL_DATA} ${WRKSRC}/_build/${ERL_BUILD_NAME}/lib/${ERL_APP_NAME}/ebin/* \ | ||||
${STAGEDIR}${ERL_APP_ROOT}/ebin | ${STAGEDIR}${ERL_APP_ROOT}/ebin | ||||
.else | . else | ||||
${INSTALL_DATA} ${WRKSRC}/ebin/* ${STAGEDIR}${ERL_APP_ROOT}/ebin | ${INSTALL_DATA} ${WRKSRC}/ebin/* ${STAGEDIR}${ERL_APP_ROOT}/ebin | ||||
.endif | . endif | ||||
if [ -d ${WRKSRC}/include ]; then \ | if [ -d ${WRKSRC}/include ]; then \ | ||||
${MKDIR} ${STAGEDIR}${ERL_APP_ROOT}/include; \ | ${MKDIR} ${STAGEDIR}${ERL_APP_ROOT}/include; \ | ||||
cd ${WRKSRC}/include && ${COPYTREE_SHARE} \* ${STAGEDIR}${ERL_APP_ROOT}/include; \ | cd ${WRKSRC}/include && ${COPYTREE_SHARE} \* ${STAGEDIR}${ERL_APP_ROOT}/include; \ | ||||
fi | fi | ||||
if [ -d ${WRKSRC}/priv ]; then \ | if [ -d ${WRKSRC}/priv ]; then \ | ||||
${MKDIR} ${STAGEDIR}${ERL_APP_ROOT}/priv; \ | ${MKDIR} ${STAGEDIR}${ERL_APP_ROOT}/priv; \ | ||||
cd ${WRKSRC}/priv && ${COPYTREE_SHARE} \* ${STAGEDIR}${ERL_APP_ROOT}/priv; \ | cd ${WRKSRC}/priv && ${COPYTREE_SHARE} \* ${STAGEDIR}${ERL_APP_ROOT}/priv; \ | ||||
fi | fi | ||||
.if ${ERL_DOCS} != "" | . if ${ERL_DOCS} != "" | ||||
@${MKDIR} ${STAGEDIR}${DOCSDIR} | @${MKDIR} ${STAGEDIR}${DOCSDIR} | ||||
.for file in ${ERL_DOCS} | . for file in ${ERL_DOCS} | ||||
if [ -d "${WRKSRC}/${file}" ]; then \ | if [ -d "${WRKSRC}/${file}" ]; then \ | ||||
cd ${WRKSRC} && ${COPYTREE_SHARE} ${file} ${STAGEDIR}${DOCSDIR}; \ | cd ${WRKSRC} && ${COPYTREE_SHARE} ${file} ${STAGEDIR}${DOCSDIR}; \ | ||||
else \ | else \ | ||||
${INSTALL_DATA} ${WRKSRC}/${file} ${STAGEDIR}${DOCSDIR}; \ | ${INSTALL_DATA} ${WRKSRC}/${file} ${STAGEDIR}${DOCSDIR}; \ | ||||
fi | fi | ||||
.endfor | . endfor | ||||
.endif # .if ${ERL_DOCS} != "" | . endif # .if ${ERL_DOCS} != "" | ||||
.if ${REBAR_TARGETS:Mescriptize} | . if ${REBAR_TARGETS:Mescriptize} | ||||
@${MKDIR} ${STAGEDIR}${PREFIX}/bin | @${MKDIR} ${STAGEDIR}${PREFIX}/bin | ||||
${INSTALL_SCRIPT} ${WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/bin | ${INSTALL_SCRIPT} ${WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/bin | ||||
.endif | . endif | ||||
.endif # !target(do-install) | . endif # !target(do-install) | ||||
.endif #!defined(_INCLUDE_USES_ERLANG_MK) | .endif #!defined(_INCLUDE_USES_ERLANG_MK) |