oasis.eclass 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. # Copyright 1999-2012 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # @ECLASS: oasis.eclass
  4. # @MAINTAINER:
  5. # ml@gentoo.org
  6. # @AUTHOR:
  7. # Original Author: Alexis Ballier <aballier@gentoo.org>
  8. # @BLURB: Provides common ebuild phases for oasis-based packages.
  9. # @DESCRIPTION:
  10. # Provides common ebuild phases for oasis-based packages.
  11. # Most of these packages will just have to inherit the eclass, set their
  12. # dependencies and the DOCS variable for base.eclass to install it and be done.
  13. #
  14. # It inherits multilib, findlib, eutils and base eclasses.
  15. # Ebuilds using oasis.eclass must be EAPI>=3.
  16. # @ECLASS-VARIABLE: OASIS_BUILD_DOCS
  17. # @DESCRIPTION:
  18. # Will make oasis_src_compile build the documentation if this variable is
  19. # defined and the doc useflag is enabled.
  20. # The eclass takes care of setting doc in IUSE but the ebuild should take care
  21. # of the extra dependencies it may need.
  22. # Set before inheriting the eclass.
  23. # @ECLASS-VARIABLE: OASIS_BUILD_TESTS
  24. # @DESCRIPTION:
  25. # Will make oasis_src_configure enable building the tests if the test useflag is
  26. # enabled. oasis_src_test will then run them.
  27. # Note that you sometimes need to enable this for src_test to be useful,
  28. # sometimes not. It has to be enabled on a per-case basis.
  29. # The eclass takes care of setting test in IUSE but the ebuild should take care
  30. # of the extra dependencies it may need.
  31. # Set before inheriting the eclass.
  32. # @ECLASS-VARIABLE: OASIS_NO_DEBUG
  33. # @DESCRIPTION:
  34. # Disable debug useflag usage. Old oasis versions did not support it so we allow
  35. # disabling it in those cases.
  36. # The eclass takes care of setting debug in IUSE.
  37. # Set before inheriting the eclass.
  38. # @ECLASS-VARIABLE: OASIS_DOC_DIR
  39. # @DESCRIPTION:
  40. # Specify where to install documentation. Default is for ocamldoc HTML.
  41. # Change it before inherit if this is not what you want.
  42. # EPREFIX is automatically prepended.
  43. : ${OASIS_DOC_DIR:="/usr/share/doc/${PF}/html"}
  44. inherit multilib findlib eutils base
  45. case ${EAPI:-0} in
  46. 0|1|2) die "You need at least EAPI-3 to use oasis.eclass";;
  47. 3|4) RDEPEND=">=dev-lang/ocaml-3.12[ocamlopt?]";;
  48. *) RDEPEND=">=dev-lang/ocaml-3.12:=[ocamlopt?]";;
  49. esac
  50. IUSE="+ocamlopt"
  51. [ -n "${OASIS_NO_DEBUG}" ] || IUSE="${IUSE} debug"
  52. [ -n "${OASIS_BUILD_DOCS}" ] && IUSE="${IUSE} doc"
  53. [ -n "${OASIS_BUILD_TESTS}" ] && IUSE="${IUSE} test"
  54. DEPEND="${RDEPEND}
  55. dev-ml/ocamlbuild"
  56. # @FUNCTION: oasis_use_enable
  57. # @USAGE: < useflag > < variable >
  58. # @DESCRIPTION:
  59. # A use_enable-like function for oasis configure variables.
  60. # Outputs '--override variable (true|false)', whether useflag is enabled or
  61. # not.
  62. # Typical usage: $(oasis_use_enable ocamlopt is_native) as an oasis configure
  63. # argument.
  64. oasis_use_enable() {
  65. echo "--override $2 $(usex $1 true false)"
  66. }
  67. # @FUNCTION: oasis_src_configure
  68. # @DESCRIPTION:
  69. # src_configure phase shared by oasis-based packages.
  70. # Extra arguments may be passed via oasis_configure_opts.
  71. oasis_src_configure() {
  72. local confargs=""
  73. [ -n "${OASIS_BUILD_TESTS}" ] && confargs="${confargs} $(use_enable test tests)"
  74. [ -n "${OASIS_NO_DEBUG}" ] || confargs="${confargs} $(oasis_use_enable debug debug)"
  75. ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -configure \
  76. --prefix "${ED}/usr" \
  77. --libdir "${ED}/usr/$(get_libdir)" \
  78. --docdir "${ED}${OASIS_DOC_DIR}" \
  79. $(oasis_use_enable ocamlopt is_native) \
  80. ${confargs} \
  81. ${oasis_configure_opts} \
  82. || die
  83. }
  84. # @FUNCTION: oasis_src_compile
  85. # @DESCRIPTION:
  86. # Builds an oasis-based package.
  87. # Will build documentation if OASIS_BUILD_DOCS is defined and the doc useflag is
  88. # enabled.
  89. oasis_src_compile() {
  90. ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -build || die
  91. if [ -n "${OASIS_BUILD_DOCS}" ] && use doc; then
  92. ocaml setup.ml -doc || die
  93. fi
  94. }
  95. # @FUNCTION: oasis_src_test
  96. # @DESCRIPTION:
  97. # Runs the testsuite of an oasis-based package.
  98. oasis_src_test() {
  99. LD_LIBRARY_PATH="${S}/_build/lib" ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -test || die
  100. }
  101. # @FUNCTION: oasis_src_install
  102. # @DESCRIPTION:
  103. # Installs an oasis-based package.
  104. # It calls base_src_install_docs, so will install documentation declared in the
  105. # DOCS variable.
  106. oasis_src_install() {
  107. findlib_src_preinst
  108. ${OASIS_SETUP_COMMAND:-ocaml setup.ml} -install || die
  109. base_src_install_docs
  110. }
  111. EXPORT_FUNCTIONS src_configure src_compile src_test src_install