xref: /OK3568_Linux_fs/buildroot/docs/manual/adding-packages-rebar.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun// -*- mode:doc; -*-
2*4882a593Smuzhiyun// vim: set syntax=asciidoc:
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun=== Infrastructure for rebar-based packages
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun[[rebar-package-tutorial]]
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun==== +rebar-package+ tutorial
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunFirst, let's see how to write a +.mk+ file for a rebar-based package,
11*4882a593Smuzhiyunwith an example :
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun------------------------------
14*4882a593Smuzhiyun01: ################################################################################
15*4882a593Smuzhiyun02: #
16*4882a593Smuzhiyun03: # erlang-foobar
17*4882a593Smuzhiyun04: #
18*4882a593Smuzhiyun05: ################################################################################
19*4882a593Smuzhiyun06:
20*4882a593Smuzhiyun07: ERLANG_FOOBAR_VERSION = 1.0
21*4882a593Smuzhiyun08: ERLANG_FOOBAR_SOURCE = erlang-foobar-$(ERLANG_FOOBAR_VERSION).tar.xz
22*4882a593Smuzhiyun09: ERLANG_FOOBAR_SITE = http://www.foosoftware.org/download
23*4882a593Smuzhiyun10: ERLANG_FOOBAR_DEPENDENCIES = host-libaaa libbbb
24*4882a593Smuzhiyun11:
25*4882a593Smuzhiyun12: $(eval $(rebar-package))
26*4882a593Smuzhiyun--------------------------------
27*4882a593Smuzhiyun
28*4882a593SmuzhiyunOn line 7, we declare the version of the package.
29*4882a593Smuzhiyun
30*4882a593SmuzhiyunOn line 8 and 9, we declare the name of the tarball (xz-ed tarball
31*4882a593Smuzhiyunrecommended) and the location of the tarball on the Web. Buildroot
32*4882a593Smuzhiyunwill automatically download the tarball from this location.
33*4882a593Smuzhiyun
34*4882a593SmuzhiyunOn line 10, we declare our dependencies, so that they are built
35*4882a593Smuzhiyunbefore the build process of our package starts.
36*4882a593Smuzhiyun
37*4882a593SmuzhiyunFinally, on line 12, we invoke the +rebar-package+ macro that
38*4882a593Smuzhiyungenerates all the Makefile rules that actually allows the package to
39*4882a593Smuzhiyunbe built.
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun[[rebar-package-reference]]
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun==== +rebar-package+ reference
44*4882a593Smuzhiyun
45*4882a593SmuzhiyunThe main macro of the +rebar+ package infrastructure is
46*4882a593Smuzhiyun+rebar-package+. It is similar to the +generic-package+ macro. The
47*4882a593Smuzhiyunability to have host packages is also available, with the
48*4882a593Smuzhiyun+host-rebar-package+ macro.
49*4882a593Smuzhiyun
50*4882a593SmuzhiyunJust like the generic infrastructure, the +rebar+ infrastructure works
51*4882a593Smuzhiyunby defining a number of variables before calling the +rebar-package+
52*4882a593Smuzhiyunmacro.
53*4882a593Smuzhiyun
54*4882a593SmuzhiyunFirst, all the package metadata information variables that exist in
55*4882a593Smuzhiyunthe generic infrastructure also exist in the +rebar+ infrastructure:
56*4882a593Smuzhiyun+ERLANG_FOOBAR_VERSION+, +ERLANG_FOOBAR_SOURCE+,
57*4882a593Smuzhiyun+ERLANG_FOOBAR_PATCH+, +ERLANG_FOOBAR_SITE+,
58*4882a593Smuzhiyun+ERLANG_FOOBAR_SUBDIR+, +ERLANG_FOOBAR_DEPENDENCIES+,
59*4882a593Smuzhiyun+ERLANG_FOOBAR_INSTALL_STAGING+, +ERLANG_FOOBAR_INSTALL_TARGET+,
60*4882a593Smuzhiyun+ERLANG_FOOBAR_LICENSE+ and +ERLANG_FOOBAR_LICENSE_FILES+.
61*4882a593Smuzhiyun
62*4882a593SmuzhiyunA few additional variables, specific to the +rebar+ infrastructure,
63*4882a593Smuzhiyuncan also be defined. Many of them are only useful in very specific
64*4882a593Smuzhiyuncases, typical packages will therefore only use a few of them.
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun* +ERLANG_FOOBAR_USE_AUTOCONF+, to specify that the package uses
67*4882a593Smuzhiyun  _autoconf_ at the configuration step.  When a package sets this
68*4882a593Smuzhiyun  variable to +YES+, the +autotools+ infrastructure is used.
69*4882a593Smuzhiyun+
70*4882a593Smuzhiyun.Note
71*4882a593SmuzhiyunYou can also use some of the variables from the +autotools+
72*4882a593Smuzhiyun  infrastructure: +ERLANG_FOOBAR_CONF_ENV+, +ERLANG_FOOBAR_CONF_OPTS+,
73*4882a593Smuzhiyun  +ERLANG_FOOBAR_AUTORECONF+, +ERLANG_FOOBAR_AUTORECONF_ENV+ and
74*4882a593Smuzhiyun  +ERLANG_FOOBAR_AUTORECONF_OPTS+.
75*4882a593Smuzhiyun
76*4882a593Smuzhiyun* +ERLANG_FOOBAR_USE_BUNDLED_REBAR+, to specify that the package has
77*4882a593Smuzhiyun  a bundled version of _rebar_ *and* that it shall be used. Valid
78*4882a593Smuzhiyun  values are +YES+ or +NO+ (the default).
79*4882a593Smuzhiyun+
80*4882a593Smuzhiyun.Note
81*4882a593SmuzhiyunIf the package bundles a _rebar_ utility, but can use the generic
82*4882a593Smuzhiyun  one that Buildroot provides, just say +NO+ (i.e., do not specify
83*4882a593Smuzhiyun  this variable). Only set if it is mandatory to use the _rebar_
84*4882a593Smuzhiyun  utility bundled in this package.
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun* +ERLANG_FOOBAR_REBAR_ENV+, to specify additional environment
87*4882a593Smuzhiyun  variables to pass to the _rebar_ utility.
88*4882a593Smuzhiyun
89*4882a593Smuzhiyun* +ERLANG_FOOBAR_KEEP_DEPENDENCIES+, to keep the dependencies
90*4882a593Smuzhiyun  described in the rebar.config file. Valid values are +YES+ or +NO+
91*4882a593Smuzhiyun  (the default). Unless this variable is set to +YES+, the _rebar_
92*4882a593Smuzhiyun  infrastructure removes such dependencies in a post-patch hook to
93*4882a593Smuzhiyun  ensure rebar does not download nor compile them.
94*4882a593Smuzhiyun
95*4882a593SmuzhiyunWith the rebar infrastructure, all the steps required to build
96*4882a593Smuzhiyunand install the packages are already defined, and they generally work
97*4882a593Smuzhiyunwell for most rebar-based packages. However, when required, it is
98*4882a593Smuzhiyunstill possible to customize what is done in any particular step:
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun* By adding a post-operation hook (after extract, patch, configure,
101*4882a593Smuzhiyun  build or install). See xref:hooks[] for details.
102*4882a593Smuzhiyun
103*4882a593Smuzhiyun* By overriding one of the steps. For example, even if the rebar
104*4882a593Smuzhiyun  infrastructure is used, if the package +.mk+ file defines its
105*4882a593Smuzhiyun  own +ERLANG_FOOBAR_BUILD_CMDS+ variable, it will be used instead
106*4882a593Smuzhiyun  of the default rebar one. However, using this method should be
107*4882a593Smuzhiyun  restricted to very specific cases. Do not use it in the general
108*4882a593Smuzhiyun  case.
109