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