adding-packages-rebar.adoc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // -*- mode:doc; -*-
  2. // vim: set syntax=asciidoc:
  3. === Infrastructure for rebar-based packages
  4. [[rebar-package-tutorial]]
  5. ==== +rebar-package+ tutorial
  6. First, let's see how to write a +.mk+ file for a rebar-based package,
  7. with an example :
  8. ----
  9. 01: ################################################################################
  10. 02: #
  11. 03: # erlang-foobar
  12. 04: #
  13. 05: ################################################################################
  14. 06:
  15. 07: ERLANG_FOOBAR_VERSION = 1.0
  16. 08: ERLANG_FOOBAR_SOURCE = erlang-foobar-$(ERLANG_FOOBAR_VERSION).tar.xz
  17. 09: ERLANG_FOOBAR_SITE = http://www.foosoftware.org/download
  18. 10: ERLANG_FOOBAR_DEPENDENCIES = host-libaaa libbbb
  19. 11:
  20. 12: $(eval $(rebar-package))
  21. ----
  22. On line 7, we declare the version of the package.
  23. On line 8 and 9, we declare the name of the tarball (xz-ed tarball
  24. recommended) and the location of the tarball on the Web. Buildroot
  25. will automatically download the tarball from this location.
  26. On line 10, we declare our dependencies, so that they are built
  27. before the build process of our package starts.
  28. Finally, on line 12, we invoke the +rebar-package+ macro that
  29. generates all the Makefile rules that actually allows the package to
  30. be built.
  31. [[rebar-package-reference]]
  32. ==== +rebar-package+ reference
  33. The main macro of the +rebar+ package infrastructure is
  34. +rebar-package+. It is similar to the +generic-package+ macro. The
  35. ability to have host packages is also available, with the
  36. +host-rebar-package+ macro.
  37. Just like the generic infrastructure, the +rebar+ infrastructure works
  38. by defining a number of variables before calling the +rebar-package+
  39. macro.
  40. All the package metadata information variables that exist in the
  41. xref:generic-package-reference[generic package infrastructure] also
  42. exist in the +rebar+ infrastructure.
  43. A few additional variables, specific to the +rebar+ infrastructure,
  44. can also be defined. Many of them are only useful in very specific
  45. cases, typical packages will therefore only use a few of them.
  46. * +ERLANG_FOOBAR_USE_AUTOCONF+, to specify that the package uses
  47. _autoconf_ at the configuration step. When a package sets this
  48. variable to +YES+, the +autotools+ infrastructure is used.
  49. +
  50. .Note
  51. You can also use some of the variables from the +autotools+
  52. infrastructure: +ERLANG_FOOBAR_CONF_ENV+, +ERLANG_FOOBAR_CONF_OPTS+,
  53. +ERLANG_FOOBAR_AUTORECONF+, +ERLANG_FOOBAR_AUTORECONF_ENV+ and
  54. +ERLANG_FOOBAR_AUTORECONF_OPTS+.
  55. * +ERLANG_FOOBAR_USE_BUNDLED_REBAR+, to specify that the package has
  56. a bundled version of _rebar_ *and* that it shall be used. Valid
  57. values are +YES+ or +NO+ (the default).
  58. +
  59. .Note
  60. If the package bundles a _rebar_ utility, but can use the generic
  61. one that Buildroot provides, just say +NO+ (i.e., do not specify
  62. this variable). Only set if it is mandatory to use the _rebar_
  63. utility bundled in this package.
  64. * +ERLANG_FOOBAR_REBAR_ENV+, to specify additional environment
  65. variables to pass to the _rebar_ utility.
  66. * +ERLANG_FOOBAR_KEEP_DEPENDENCIES+, to keep the dependencies
  67. described in the rebar.config file. Valid values are +YES+ or +NO+
  68. (the default). Unless this variable is set to +YES+, the _rebar_
  69. infrastructure removes such dependencies in a post-patch hook to
  70. ensure rebar does not download nor compile them.
  71. With the rebar infrastructure, all the steps required to build
  72. and install the packages are already defined, and they generally work
  73. well for most rebar-based packages. However, when required, it is
  74. still possible to customize what is done in any particular step:
  75. * By adding a post-operation hook (after extract, patch, configure,
  76. build or install). See xref:hooks[] for details.
  77. * By overriding one of the steps. For example, even if the rebar
  78. infrastructure is used, if the package +.mk+ file defines its
  79. own +ERLANG_FOOBAR_BUILD_CMDS+ variable, it will be used instead
  80. of the default rebar one. However, using this method should be
  81. restricted to very specific cases. Do not use it in the general
  82. case.