xref: /OK3568_Linux_fs/buildroot/docs/manual/adding-packages-waf.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun// -*- mode:doc; -*-
2*4882a593Smuzhiyun// vim: set syntax=asciidoc:
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun=== Infrastructure for Waf-based packages
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun[[waf-package-tutorial]]
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun==== +waf-package+ tutorial
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunFirst, let's see how to write a +.mk+ file for a Waf-based package, with
11*4882a593Smuzhiyunan example :
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun------------------------
14*4882a593Smuzhiyun01: ################################################################################
15*4882a593Smuzhiyun02: #
16*4882a593Smuzhiyun03: # libfoo
17*4882a593Smuzhiyun04: #
18*4882a593Smuzhiyun05: ################################################################################
19*4882a593Smuzhiyun06:
20*4882a593Smuzhiyun07: LIBFOO_VERSION = 1.0
21*4882a593Smuzhiyun08: LIBFOO_SOURCE = libfoo-$(LIBFOO_VERSION).tar.gz
22*4882a593Smuzhiyun09: LIBFOO_SITE = http://www.foosoftware.org/download
23*4882a593Smuzhiyun10: LIBFOO_CONF_OPTS = --enable-bar --disable-baz
24*4882a593Smuzhiyun11: LIBFOO_DEPENDENCIES = bar
25*4882a593Smuzhiyun12:
26*4882a593Smuzhiyun13: $(eval $(waf-package))
27*4882a593Smuzhiyun------------------------
28*4882a593Smuzhiyun
29*4882a593SmuzhiyunOn line 7, we declare the version of the package.
30*4882a593Smuzhiyun
31*4882a593SmuzhiyunOn line 8 and 9, we declare the name of the tarball (xz-ed tarball
32*4882a593Smuzhiyunrecommended) and the location of the tarball on the Web. Buildroot
33*4882a593Smuzhiyunwill automatically download the tarball from this location.
34*4882a593Smuzhiyun
35*4882a593SmuzhiyunOn line 10, we tell Buildroot what options to enable for libfoo.
36*4882a593Smuzhiyun
37*4882a593SmuzhiyunOn line 11, we tell Buildroot the dependencies of libfoo.
38*4882a593Smuzhiyun
39*4882a593SmuzhiyunFinally, on line line 13, we invoke the +waf-package+
40*4882a593Smuzhiyunmacro that generates all the Makefile rules that actually allows the
41*4882a593Smuzhiyunpackage to be built.
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun[[waf-package-reference]]
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun==== +waf-package+ reference
46*4882a593Smuzhiyun
47*4882a593SmuzhiyunThe main macro of the Waf package infrastructure is +waf-package+.
48*4882a593SmuzhiyunIt is similar to the +generic-package+ macro.
49*4882a593Smuzhiyun
50*4882a593SmuzhiyunJust like the generic infrastructure, the Waf infrastructure works
51*4882a593Smuzhiyunby defining a number of variables before calling the +waf-package+
52*4882a593Smuzhiyunmacro.
53*4882a593Smuzhiyun
54*4882a593SmuzhiyunFirst, all the package metadata information variables that exist in
55*4882a593Smuzhiyunthe generic infrastructure also exist in the Waf infrastructure:
56*4882a593Smuzhiyun+LIBFOO_VERSION+, +LIBFOO_SOURCE+, +LIBFOO_PATCH+, +LIBFOO_SITE+,
57*4882a593Smuzhiyun+LIBFOO_SUBDIR+, +LIBFOO_DEPENDENCIES+, +LIBFOO_INSTALL_STAGING+,
58*4882a593Smuzhiyun+LIBFOO_INSTALL_TARGET+.
59*4882a593Smuzhiyun
60*4882a593SmuzhiyunAn additional variable, specific to the Waf infrastructure, can
61*4882a593Smuzhiyunalso be defined.
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun* +LIBFOO_SUBDIR+ may contain the name of a subdirectory inside the
64*4882a593Smuzhiyun  package that contains the main wscript file. This is useful,
65*4882a593Smuzhiyun  if for example, the main wscript file is not at the root of
66*4882a593Smuzhiyun  the tree extracted by the tarball. If +HOST_LIBFOO_SUBDIR+ is not
67*4882a593Smuzhiyun  specified, it defaults to +LIBFOO_SUBDIR+.
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun* +LIBFOO_NEEDS_EXTERNAL_WAF+ can be set to +YES+ or +NO+ to tell
70*4882a593Smuzhiyun  Buildroot to use the bundled +waf+ executable. If set to +NO+, the
71*4882a593Smuzhiyun  default, then Buildroot will use the waf executable provided in the
72*4882a593Smuzhiyun  package source tree; if set to +YES+, then Buildroot will download,
73*4882a593Smuzhiyun  install waf as a host tool and use it to build the package.
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun* +LIBFOO_WAF_OPTS+, to specify additional options to pass to the
76*4882a593Smuzhiyun  +waf+ script at every step of the package build process: configure,
77*4882a593Smuzhiyun  build and installation. By default, empty.
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun* +LIBFOO_CONF_OPTS+, to specify additional options to pass to the
80*4882a593Smuzhiyun  +waf+ script for the configuration step. By default, empty.
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun* +LIBFOO_BUILD_OPTS+, to specify additional options to pass to the
83*4882a593Smuzhiyun  +waf+ script during the build step. By default, empty.
84*4882a593Smuzhiyun
85*4882a593Smuzhiyun* +LIBFOO_INSTALL_STAGING_OPTS+, to specify additional options to pass
86*4882a593Smuzhiyun  to the +waf+ script during the staging installation step.  By default,
87*4882a593Smuzhiyun  empty.
88*4882a593Smuzhiyun
89*4882a593Smuzhiyun* +LIBFOO_INSTALL_TARGET_OPTS+, to specify additional options to pass
90*4882a593Smuzhiyun  to the +waf+ script during the target installation step.  By default,
91*4882a593Smuzhiyun  empty.
92