erlang.port.mk 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. # $OpenBSD: erlang.port.mk,v 1.23 2016/06/30 07:19:23 jasper Exp $
  2. #
  3. # Module for Erlang-based ports or modules
  4. CATEGORIES += lang/erlang
  5. USE_GMAKE ?= Yes
  6. # Default Erlang version to use if MODERL_VERSION is not set.
  7. # XXX: Keep in sync with devel/rebar/Makefile
  8. MODERL_DEFAULT_VERSION =16
  9. # If the port already has flavors, append ours to it unless the port requires
  10. # a specific version of Erlang.
  11. .if !defined(MODERL_VERSION) && !defined(FLAVORS)
  12. FLAVORS ?= erlang17 erlang18 erlang19
  13. .else
  14. FLAVORS += erlang17 erlang18 erlang19
  15. .endif
  16. FLAVOR?= # empty
  17. # When no flavor is explicitly set, assume MODERL_DEFAULT_VERSION
  18. .if ${FLAVOR:Merlang17}
  19. MODERL_VERSION = 17
  20. _MODERL_FLAVOR = ${FLAVOR}
  21. .elif ${FLAVOR:Merlang18}
  22. MODERL_VERSION = 18
  23. _MODERL_FLAVOR = ${FLAVOR}
  24. .elif ${FLAVOR:Merlang19}
  25. MODERL_VERSION = 19
  26. _MODERL_FLAVOR = ${FLAVOR}
  27. .else
  28. MODERL_VERSION ?= ${MODERL_DEFAULT_VERSION}
  29. _MODERL_FLAVOR ?= # empty
  30. .endif
  31. .if ${MODERL_VERSION} == 16
  32. _MODERL_FLAVOR = erlang16
  33. .elif ${MODERL_VERSION} == 17
  34. _MODERL_FLAVOR = erlang17
  35. .elif ${MODERL_VERSION} == 18
  36. _MODERL_FLAVOR = erlang18
  37. .elif ${MODERL_VERSION} == 19
  38. _MODERL_FLAVOR = erlang19
  39. .else
  40. ERRORS += "Invalid MODERL_VERSION set: ${MODERL_VERSION}."
  41. .endif
  42. # If no configure style is set, then assume "rebar"
  43. .if ${CONFIGURE_STYLE} == ""
  44. CONFIGURE_STYLE = rebar
  45. MODERL_BUILD_DEPENDS += devel/rebar
  46. REBAR_BIN ?= ${LOCALBASE}/bin/rebar${MODERL_VERSION}
  47. # Make sure rebar gets called as 'rebar', otherwise escript tries to call the
  48. # binary name (e.g. rebar16) as the script entrypoint.
  49. _MODERL_LINKS += rebar${MODERL_VERSION} rebar
  50. .endif
  51. # Append the flavor to all the Erlang dependencies
  52. .for b in ${MODERL_BUILD_DEPENDS}
  53. _MODERL_BDEPS += ${b},${_MODERL_FLAVOR}
  54. .endfor
  55. .for r in ${MODERL_RUN_DEPENDS}
  56. _MODERL_RDEPS += ${r},${_MODERL_FLAVOR}
  57. .endfor
  58. .for t in ${MODERL_TEST_DEPENDS}
  59. _MODERL_TDEPS += ${t},${_MODERL_FLAVOR}
  60. .endfor
  61. MODERL_BUILDDEP ?= Yes
  62. MODERL_RUNDEP ?= Yes
  63. MODERL_WX ?= No
  64. .if ${MODERL_WX:L} == yes
  65. _MODERL_BDEPS += lang/erlang/${MODERL_VERSION},-wx
  66. _MODERL_RDEPS += lang/erlang/${MODERL_VERSION},-wx
  67. .endif
  68. .if ${MODERL_BUILDDEP:L} == yes
  69. BUILD_DEPENDS += ${_MODERL_BDEPS} \
  70. lang/erlang/${MODERL_VERSION}
  71. .endif
  72. .if ${MODERL_RUNDEP:L} == yes
  73. RUN_DEPENDS += ${_MODERL_RDEPS} \
  74. lang/erlang/${MODERL_VERSION}
  75. .endif
  76. TEST_DEPENDS += ${_MODERL_TDEPS}
  77. # Root directory of all Erlang libraries.
  78. MODERL_BASEDIR ?= ${PREFIX}/lib/erlang${MODERL_VERSION}/
  79. ERL_LIBROOT ?= ${MODERL_BASEDIR}/lib
  80. MODERL_LIBROOT ?= lib/erlang${MODERL_VERSION}/lib
  81. # Standard directory into which a module/library gets installed.
  82. ERL_LIBDIR ?= ${ERL_LIBROOT}/${DISTNAME}
  83. # Common program shortcuts
  84. MODERL_ERL = ${LOCALBASE}/bin/erl${MODERL_VERSION}
  85. MODERL_ERLC = ${LOCALBASE}/bin/erlc${MODERL_VERSION}
  86. # In order to prevent patching every single Erlang-using port (there's no
  87. # pkg-config like system to retrieve binary names), symlink the binaries
  88. # the build will use.
  89. _MODERL_LINKS += erl${MODERL_VERSION} erl \
  90. erlc${MODERL_VERSION} erlc \
  91. erl_call${MODERL_VERSION} erl_call \
  92. escript${MODERL_VERSION} escript
  93. .if !empty(_MODERL_LINKS)
  94. . for _src _dest in ${_MODERL_LINKS}
  95. MODERLANG_post-patch += ln -sf ${LOCALBASE}/bin/${_src} ${WRKDIR}/bin/${_dest};
  96. . endfor
  97. .endif
  98. # Some modules don't have a 'version' set and try to retrieve this through git.
  99. # Patch the .app.src files to have ${VERSION} and set ERL_APP_SUBST=Yes.
  100. .if defined(ERL_APP_SUBST) && ${ERL_APP_SUBST:L} == "yes"
  101. .if ! target(pre-configure)
  102. pre-configure:
  103. cd ${WRKSRC}/src/ && ${SUBST_CMD} *.app.src
  104. .endif
  105. .endif
  106. .if ${CONFIGURE_STYLE:L} == "rebar"
  107. # Some modules bundle their own rebar escript, force them to use the system
  108. # rebar instead.
  109. # While here, remove the deps{} block from rebar.config, we cannot download
  110. # dependencies on the fly (blocked by systrace) and it obfuscates dependency
  111. # management from the ports Makefile.
  112. . if ! target(pre-build)
  113. pre-build:
  114. @cp -f ${REBAR_BIN} ${WRKSRC}/rebar
  115. @perl -pi -e 'BEGIN{undef $$/;} s/{deps,.*?]}.//smg' ${WRKSRC}/rebar.config
  116. . endif
  117. .endif
  118. # Regression test handing:
  119. # If nothing is explicitly set, then MODERL_TEST=Yes and default
  120. # target 'test' is used. Otherwise, if MODERL_TEST=eunit, then
  121. # TEST_TARGET=eunit
  122. .if defined(NO_TEST) && ${NO_TEST:L:Mno}
  123. . if ! defined(MODERL_TEST) || \
  124. defined(MODERL_TEST) && ${MODERL_TEST:L:Myes}
  125. TEST_TARGET ?= test
  126. . elif defined(MODERL_TEST) && ${MODERL_TEST:L:Mno}
  127. NO_TEST = yes
  128. . elif defined(MODERL_TEST) && ${MODERL_TEST:L:Meunit}
  129. TEST_TARGET ?= eunit
  130. .endif
  131. .endif
  132. # Helper target for testing code coverage.
  133. .if ! target(dialyzer)
  134. dialyzer:
  135. cd ${WRKSRC} && ${REBAR_BIN} dialyzer
  136. .endif
  137. SUBST_VARS += MODERL_BASEDIR MODERL_LIBROOT VERSION MODERL_VERSION