2
1

adding-packages-generic.adoc 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. // -*- mode:doc; -*-
  2. // vim: set syntax=asciidoc:
  3. === Infrastructure for packages with specific build systems
  4. By 'packages with specific build systems' we mean all the packages
  5. whose build system is not one of the standard ones, such as
  6. 'autotools' or 'CMake'. This typically includes packages whose build
  7. system is based on hand-written Makefiles or shell scripts.
  8. [[generic-package-tutorial]]
  9. ==== +generic-package+ tutorial
  10. ------------------------------
  11. 01: ################################################################################
  12. 02: #
  13. 03: # libfoo
  14. 04: #
  15. 05: ################################################################################
  16. 06:
  17. 07: LIBFOO_VERSION = 1.0
  18. 08: LIBFOO_SOURCE = libfoo-$(LIBFOO_VERSION).tar.gz
  19. 09: LIBFOO_SITE = http://www.foosoftware.org/download
  20. 10: LIBFOO_LICENSE = GPL-3.0+
  21. 11: LIBFOO_LICENSE_FILES = COPYING
  22. 12: LIBFOO_INSTALL_STAGING = YES
  23. 13: LIBFOO_CONFIG_SCRIPTS = libfoo-config
  24. 14: LIBFOO_DEPENDENCIES = host-libaaa libbbb
  25. 15:
  26. 16: define LIBFOO_BUILD_CMDS
  27. 17: $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) all
  28. 18: endef
  29. 19:
  30. 20: define LIBFOO_INSTALL_STAGING_CMDS
  31. 21: $(INSTALL) -D -m 0755 $(@D)/libfoo.a $(STAGING_DIR)/usr/lib/libfoo.a
  32. 22: $(INSTALL) -D -m 0644 $(@D)/foo.h $(STAGING_DIR)/usr/include/foo.h
  33. 23: $(INSTALL) -D -m 0755 $(@D)/libfoo.so* $(STAGING_DIR)/usr/lib
  34. 24: endef
  35. 25:
  36. 26: define LIBFOO_INSTALL_TARGET_CMDS
  37. 27: $(INSTALL) -D -m 0755 $(@D)/libfoo.so* $(TARGET_DIR)/usr/lib
  38. 28: $(INSTALL) -d -m 0755 $(TARGET_DIR)/etc/foo.d
  39. 29: endef
  40. 30:
  41. 31: define LIBFOO_USERS
  42. 32: foo -1 libfoo -1 * - - - LibFoo daemon
  43. 33: endef
  44. 34:
  45. 35: define LIBFOO_DEVICES
  46. 36: /dev/foo c 666 0 0 42 0 - - -
  47. 37: endef
  48. 38:
  49. 39: define LIBFOO_PERMISSIONS
  50. 40: /bin/foo f 4755 foo libfoo - - - - -
  51. 41: endef
  52. 42:
  53. 43: $(eval $(generic-package))
  54. --------------------------------
  55. The Makefile begins on line 7 to 11 with metadata information: the
  56. version of the package (+LIBFOO_VERSION+), the name of the
  57. tarball containing the package (+LIBFOO_SOURCE+) (xz-ed tarball recommended)
  58. the Internet location at which the tarball can be downloaded from
  59. (+LIBFOO_SITE+), the license (+LIBFOO_LICENSE+) and file with the
  60. license text (+LIBFOO_LICENSE_FILES+). All variables must start with
  61. the same prefix, +LIBFOO_+ in this case. This prefix is always the
  62. uppercased version of the package name (see below to understand where
  63. the package name is defined).
  64. On line 12, we specify that this package wants to install something to
  65. the staging space. This is often needed for libraries, since they must
  66. install header files and other development files in the staging space.
  67. This will ensure that the commands listed in the
  68. +LIBFOO_INSTALL_STAGING_CMDS+ variable will be executed.
  69. On line 13, we specify that there is some fixing to be done to some
  70. of the 'libfoo-config' files that were installed during
  71. +LIBFOO_INSTALL_STAGING_CMDS+ phase.
  72. These *-config files are executable shell script files that are
  73. located in '$(STAGING_DIR)/usr/bin' directory and are executed
  74. by other 3rd party packages to find out the location and the linking
  75. flags of this particular package.
  76. The problem is that all these *-config files by default give wrong,
  77. host system linking flags that are unsuitable for cross-compiling.
  78. For example: '-I/usr/include' instead of '-I$(STAGING_DIR)/usr/include'
  79. or: '-L/usr/lib' instead of '-L$(STAGING_DIR)/usr/lib'
  80. So some sed magic is done to these scripts to make them give correct
  81. flags.
  82. The argument to be given to +LIBFOO_CONFIG_SCRIPTS+ is the file name(s)
  83. of the shell script(s) needing fixing. All these names are relative to
  84. '$(STAGING_DIR)/usr/bin' and if needed multiple names can be given.
  85. In addition, the scripts listed in +LIBFOO_CONFIG_SCRIPTS+ are removed
  86. from +$(TARGET_DIR)/usr/bin+, since they are not needed on the target.
  87. .Config script: 'divine' package
  88. ================================
  89. Package divine installs shell script '$(STAGING_DIR)/usr/bin/divine-config'.
  90. So its fixup would be:
  91. --------------------------------
  92. DIVINE_CONFIG_SCRIPTS = divine-config
  93. --------------------------------
  94. ================================
  95. .Config script: 'imagemagick' package:
  96. ================================
  97. Package imagemagick installs the following scripts:
  98. '$(STAGING_DIR)/usr/bin/{Magick,Magick++,MagickCore,MagickWand,Wand}-config'
  99. So it's fixup would be:
  100. --------------------------------
  101. IMAGEMAGICK_CONFIG_SCRIPTS = \
  102. Magick-config Magick++-config \
  103. MagickCore-config MagickWand-config Wand-config
  104. --------------------------------
  105. ================================
  106. On line 14, we specify the list of dependencies this package relies
  107. on. These dependencies are listed in terms of lower-case package names,
  108. which can be packages for the target (without the +host-+
  109. prefix) or packages for the host (with the +host-+) prefix).
  110. Buildroot will ensure that all these packages are built and installed
  111. 'before' the current package starts its configuration.
  112. The rest of the Makefile, lines 16..29, defines what should be done
  113. at the different steps of the package configuration, compilation and
  114. installation.
  115. +LIBFOO_BUILD_CMDS+ tells what steps should be performed to
  116. build the package. +LIBFOO_INSTALL_STAGING_CMDS+ tells what
  117. steps should be performed to install the package in the staging space.
  118. +LIBFOO_INSTALL_TARGET_CMDS+ tells what steps should be
  119. performed to install the package in the target space.
  120. All these steps rely on the +$(@D)+ variable, which
  121. contains the directory where the source code of the package has been
  122. extracted.
  123. On lines 31..33, we define a user that is used by this package (e.g.
  124. to run a daemon as non-root) (+LIBFOO_USERS+).
  125. On line 35..37, we define a device-node file used by this package
  126. (+LIBFOO_DEVICES+).
  127. On line 39..41, we define the permissions to set to specific files
  128. installed by this package (+LIBFOO_PERMISSIONS+).
  129. Finally, on line 43, we call the +generic-package+ function, which
  130. generates, according to the variables defined previously, all the
  131. Makefile code necessary to make your package working.
  132. [[generic-package-reference]]
  133. ==== +generic-package+ reference
  134. There are two variants of the generic target. The +generic-package+ macro is
  135. used for packages to be cross-compiled for the target. The
  136. +host-generic-package+ macro is used for host packages, natively compiled
  137. for the host. It is possible to call both of them in a single +.mk+
  138. file: once to create the rules to generate a target
  139. package and once to create the rules to generate a host package:
  140. ----------------------
  141. $(eval $(generic-package))
  142. $(eval $(host-generic-package))
  143. ----------------------
  144. This might be useful if the compilation of the target package requires
  145. some tools to be installed on the host. If the package name is
  146. +libfoo+, then the name of the package for the target is also
  147. +libfoo+, while the name of the package for the host is
  148. +host-libfoo+. These names should be used in the DEPENDENCIES
  149. variables of other packages, if they depend on +libfoo+ or
  150. +host-libfoo+.
  151. The call to the +generic-package+ and/or +host-generic-package+ macro
  152. *must* be at the end of the +.mk+ file, after all variable definitions.
  153. The call to +host-generic-package+ *must* be after the call to
  154. +generic-package+, if any.
  155. For the target package, the +generic-package+ uses the variables defined by
  156. the .mk file and prefixed by the uppercased package name:
  157. +LIBFOO_*+. +host-generic-package+ uses the +HOST_LIBFOO_*+ variables. For
  158. 'some' variables, if the +HOST_LIBFOO_+ prefixed variable doesn't
  159. exist, the package infrastructure uses the corresponding variable
  160. prefixed by +LIBFOO_+. This is done for variables that are likely to
  161. have the same value for both the target and host packages. See below
  162. for details.
  163. The list of variables that can be set in a +.mk+ file to give metadata
  164. information is (assuming the package name is +libfoo+) :
  165. * +LIBFOO_VERSION+, mandatory, must contain the version of the
  166. package. Note that if +HOST_LIBFOO_VERSION+ doesn't exist, it is
  167. assumed to be the same as +LIBFOO_VERSION+. It can also be a
  168. revision number or a tag for packages that are fetched directly
  169. from their version control system. Examples:
  170. ** a version for a release tarball: +LIBFOO_VERSION = 0.1.2+
  171. ** a sha1 for a git tree: +LIBFOO_VERSION = cb9d6aa9429e838f0e54faa3d455bcbab5eef057+
  172. ** a tag for a git tree +LIBFOO_VERSION = v0.1.2+
  173. +
  174. .Note:
  175. Using a branch name as +FOO_VERSION+ is not supported, because it does
  176. not and can not work as people would expect it should:
  177. +
  178. 1. due to local caching, Buildroot will not re-fetch the repository,
  179. so people who expect to be able to follow the remote repository
  180. would be quite surprised and disappointed;
  181. 2. because two builds can never be perfectly simultaneous, and because
  182. the remote repository may get new commits on the branch anytime,
  183. two users, using the same Buildroot tree and building the same
  184. configuration, may get different source, thus rendering the build
  185. non reproducible, and people would be quite surprised and
  186. disappointed.
  187. * +LIBFOO_SOURCE+ may contain the name of the tarball of the package,
  188. which Buildroot will use to download the tarball from
  189. +LIBFOO_SITE+. If +HOST_LIBFOO_SOURCE+ is not specified, it defaults
  190. to +LIBFOO_SOURCE+. If none are specified, then the value is assumed
  191. to be +libfoo-$(LIBFOO_VERSION).tar.gz+. +
  192. Example: +LIBFOO_SOURCE = foobar-$(LIBFOO_VERSION).tar.bz2+
  193. * +LIBFOO_PATCH+ may contain a space-separated list of patch file
  194. names, that Buildroot will download and apply to the package source
  195. code. If an entry contains +://+, then Buildroot will assume it is a
  196. full URL and download the patch from this location. Otherwise,
  197. Buildroot will assume that the patch should be downloaded from
  198. +LIBFOO_SITE+. If +HOST_LIBFOO_PATCH+ is not specified, it defaults
  199. to +LIBFOO_PATCH+. Note that patches that are included in Buildroot
  200. itself use a different mechanism: all files of the form
  201. +*.patch+ present in the package directory inside
  202. Buildroot will be applied to the package after extraction (see
  203. xref:patch-policy[patching a package]). Finally, patches listed in
  204. the +LIBFOO_PATCH+ variable are applied _before_ the patches stored
  205. in the Buildroot package directory.
  206. * +LIBFOO_SITE+ provides the location of the package, which can be a
  207. URL or a local filesystem path. HTTP, FTP and SCP are supported URL
  208. types for retrieving package tarballs. In these cases don't include a
  209. trailing slash: it will be added by Buildroot between the directory
  210. and the filename as appropriate. Git, Subversion, Mercurial,
  211. and Bazaar are supported URL types for retrieving packages directly
  212. from source code management systems. There is a helper function to make
  213. it easier to download source tarballs from GitHub (refer to
  214. xref:github-download-url[] for details). A filesystem path may be used
  215. to specify either a tarball or a directory containing the package
  216. source code. See +LIBFOO_SITE_METHOD+ below for more details on how
  217. retrieval works. +
  218. Note that SCP URLs should be of the form
  219. +scp://[user@]host:filepath+, and that filepath is relative to the
  220. user's home directory, so you may want to prepend the path with a
  221. slash for absolute paths:
  222. +scp://[user@]host:/absolutepath+. The same goes for SFTP URLs. +
  223. If +HOST_LIBFOO_SITE+ is not specified, it defaults to
  224. +LIBFOO_SITE+.
  225. Examples: +
  226. +LIBFOO_SITE=http://www.libfoosoftware.org/libfoo+ +
  227. +LIBFOO_SITE=http://svn.xiph.org/trunk/Tremor+ +
  228. +LIBFOO_SITE=/opt/software/libfoo.tar.gz+ +
  229. +LIBFOO_SITE=$(TOPDIR)/../src/libfoo+
  230. * +LIBFOO_DL_OPTS+ is a space-separated list of additional options to
  231. pass to the downloader. Useful for retrieving documents with
  232. server-side checking for user logins and passwords, or to use a proxy.
  233. All download methods valid for +LIBFOO_SITE_METHOD+ are supported;
  234. valid options depend on the download method (consult the man page
  235. for the respective download utilities).
  236. * +LIBFOO_EXTRA_DOWNLOADS+ is a space-separated list of additional
  237. files that Buildroot should download. If an entry contains +://+
  238. then Buildroot will assume it is a complete URL and will download
  239. the file using this URL. Otherwise, Buildroot will assume the file
  240. to be downloaded is located at +LIBFOO_SITE+. Buildroot will not do
  241. anything with those additional files, except download them: it will
  242. be up to the package recipe to use them from +$(LIBFOO_DL_DIR)+.
  243. * +LIBFOO_SITE_METHOD+ determines the method used to fetch or copy the
  244. package source code. In many cases, Buildroot guesses the method
  245. from the contents of +LIBFOO_SITE+ and setting +LIBFOO_SITE_METHOD+
  246. is unnecessary. When +HOST_LIBFOO_SITE_METHOD+ is not specified, it
  247. defaults to the value of +LIBFOO_SITE_METHOD+. +
  248. The possible values of +LIBFOO_SITE_METHOD+ are:
  249. ** +wget+ for normal FTP/HTTP downloads of tarballs. Used by
  250. default when +LIBFOO_SITE+ begins with +http://+, +https://+ or
  251. +ftp://+.
  252. ** +scp+ for downloads of tarballs over SSH with scp. Used by
  253. default when +LIBFOO_SITE+ begins with +scp://+.
  254. ** +sftp+ for downloads of tarballs over SSH with sftp. Used by
  255. default when +LIBFOO_SITE+ begins with +sftp://+.
  256. ** +svn+ for retrieving source code from a Subversion repository.
  257. Used by default when +LIBFOO_SITE+ begins with +svn://+. When a
  258. +http://+ Subversion repository URL is specified in
  259. +LIBFOO_SITE+, one 'must' specify +LIBFOO_SITE_METHOD=svn+.
  260. Buildroot performs a checkout which is preserved as a tarball in
  261. the download cache; subsequent builds use the tarball instead of
  262. performing another checkout.
  263. ** +cvs+ for retrieving source code from a CVS repository.
  264. Used by default when +LIBFOO_SITE+ begins with +cvs://+.
  265. The downloaded source code is cached as with the +svn+ method.
  266. Anonymous pserver mode is assumed otherwise explicitly defined
  267. on +LIBFOO_SITE+. Both
  268. +LIBFOO_SITE=cvs://libfoo.net:/cvsroot/libfoo+ and
  269. +LIBFOO_SITE=cvs://:ext:libfoo.net:/cvsroot/libfoo+
  270. are accepted, on the former anonymous pserver access mode is
  271. assumed.
  272. +LIBFOO_SITE+ 'must' contain the source URL as well as the remote
  273. repository directory. The module is the package name.
  274. +LIBFOO_VERSION+ is 'mandatory' and 'must' be a tag, a branch, or
  275. a date (e.g. "2014-10-20", "2014-10-20 13:45", "2014-10-20
  276. 13:45+01" see "man cvs" for further details).
  277. ** +git+ for retrieving source code from a Git repository. Used by
  278. default when +LIBFOO_SITE+ begins with +git://+. The downloaded
  279. source code is cached as with the +svn+ method.
  280. ** +hg+ for retrieving source code from a Mercurial repository. One
  281. 'must' specify +LIBFOO_SITE_METHOD=hg+ when +LIBFOO_SITE+
  282. contains a Mercurial repository URL. The downloaded source code
  283. is cached as with the +svn+ method.
  284. ** +bzr+ for retrieving source code from a Bazaar repository. Used
  285. by default when +LIBFOO_SITE+ begins with +bzr://+. The
  286. downloaded source code is cached as with the +svn+ method.
  287. ** +file+ for a local tarball. One should use this when
  288. +LIBFOO_SITE+ specifies a package tarball as a local filename.
  289. Useful for software that isn't available publicly or in version
  290. control.
  291. ** +local+ for a local source code directory. One should use this
  292. when +LIBFOO_SITE+ specifies a local directory path containing
  293. the package source code. Buildroot copies the contents of the
  294. source directory into the package's build directory. Note that
  295. for +local+ packages, no patches are applied. If you need to
  296. still patch the source code, use +LIBFOO_POST_RSYNC_HOOKS+, see
  297. xref:hooks-rsync[].
  298. * +LIBFOO_GIT_SUBMODULES+ can be set to +YES+ to create an archive
  299. with the git submodules in the repository. This is only available
  300. for packages downloaded with git (i.e. when
  301. +LIBFOO_SITE_METHOD=git+). Note that we try not to use such git
  302. submodules when they contain bundled libraries, in which case we
  303. prefer to use those libraries from their own package.
  304. * +LIBFOO_GIT_LFS+ should be set to +YES+ if the Git repository uses
  305. Git LFS to store large files out of band. This is only available for
  306. packages downloaded with git (i.e. when +LIBFOO_SITE_METHOD=git+).
  307. * +LIBFOO_SVN_EXTERNALS+ can be set to +YES+ to create an archive with
  308. the svn external references. This is only available for packages
  309. downloaded with subversion.
  310. * +LIBFOO_STRIP_COMPONENTS+ is the number of leading components
  311. (directories) that tar must strip from file names on extraction.
  312. The tarball for most packages has one leading component named
  313. "<pkg-name>-<pkg-version>", thus Buildroot passes
  314. --strip-components=1 to tar to remove it.
  315. For non-standard packages that don't have this component, or
  316. that have more than one leading component to strip, set this
  317. variable with the value to be passed to tar. Default: 1.
  318. * +LIBFOO_EXCLUDES+ is a space-separated list of patterns to exclude
  319. when extracting the archive. Each item from that list is passed as
  320. a tar's +--exclude+ option. By default, empty.
  321. * +LIBFOO_DEPENDENCIES+ lists the dependencies (in terms of package
  322. name) that are required for the current target package to
  323. compile. These dependencies are guaranteed to be compiled and
  324. installed before the configuration of the current package starts.
  325. However, modifications to configuration of these dependencies will
  326. not force a rebuild of the current package. In a similar way,
  327. +HOST_LIBFOO_DEPENDENCIES+ lists the dependencies for the current
  328. host package.
  329. * +LIBFOO_EXTRACT_DEPENDENCIES+ lists the dependencies (in terms of
  330. package name) that are required for the current target package to be
  331. extracted. These dependencies are guaranteed to be compiled and
  332. installed before the extract step of the current package
  333. starts. This is only used internally by the package infrastructure,
  334. and should typically not be used directly by packages.
  335. * +LIBFOO_PATCH_DEPENDENCIES+ lists the dependencies (in terms of
  336. package name) that are required for the current package to be
  337. patched. These dependencies are guaranteed to be extracted and
  338. patched (but not necessarily built) before the current package is
  339. patched. In a similar way, +HOST_LIBFOO_PATCH_DEPENDENCIES+ lists
  340. the dependencies for the current host package.
  341. This is seldom used; usually, +LIBFOO_DEPENDENCIES+ is what you
  342. really want to use.
  343. * +LIBFOO_PROVIDES+ lists all the virtual packages +libfoo+ is an
  344. implementation of. See xref:virtual-package-tutorial[].
  345. * +LIBFOO_INSTALL_STAGING+ can be set to +YES+ or +NO+ (default). If
  346. set to +YES+, then the commands in the +LIBFOO_INSTALL_STAGING_CMDS+
  347. variables are executed to install the package into the staging
  348. directory.
  349. * +LIBFOO_INSTALL_TARGET+ can be set to +YES+ (default) or +NO+. If
  350. set to +YES+, then the commands in the +LIBFOO_INSTALL_TARGET_CMDS+
  351. variables are executed to install the package into the target
  352. directory.
  353. * +LIBFOO_INSTALL_IMAGES+ can be set to +YES+ or +NO+ (default). If
  354. set to +YES+, then the commands in the +LIBFOO_INSTALL_IMAGES_CMDS+
  355. variable are executed to install the package into the images
  356. directory.
  357. * +LIBFOO_CONFIG_SCRIPTS+ lists the names of the files in
  358. '$(STAGING_DIR)/usr/bin' that need some special fixing to make them
  359. cross-compiling friendly. Multiple file names separated by space can
  360. be given and all are relative to '$(STAGING_DIR)/usr/bin'. The files
  361. listed in +LIBFOO_CONFIG_SCRIPTS+ are also removed from
  362. +$(TARGET_DIR)/usr/bin+ since they are not needed on the target.
  363. * +LIBFOO_DEVICES+ lists the device files to be created by Buildroot
  364. when using the static device table. The syntax to use is the
  365. makedevs one. You can find some documentation for this syntax in the
  366. xref:makedev-syntax[]. This variable is optional.
  367. * +LIBFOO_PERMISSIONS+ lists the changes of permissions to be done at
  368. the end of the build process. The syntax is once again the makedevs one.
  369. You can find some documentation for this syntax in the xref:makedev-syntax[].
  370. This variable is optional.
  371. * +LIBFOO_USERS+ lists the users to create for this package, if it installs
  372. a program you want to run as a specific user (e.g. as a daemon, or as a
  373. cron-job). The syntax is similar in spirit to the makedevs one, and is
  374. described in the xref:makeuser-syntax[]. This variable is optional.
  375. * +LIBFOO_LICENSE+ defines the license (or licenses) under which the package
  376. is released.
  377. This name will appear in the manifest file produced by +make legal-info+.
  378. If the license appears in https://spdx.org/licenses/[the SPDX License List],
  379. use the SPDX short identifier to make the manifest file uniform.
  380. Otherwise, describe the license in a precise and concise way, avoiding
  381. ambiguous names such as +BSD+ which actually name a family of licenses.
  382. This variable is optional. If it is not defined, +unknown+ will appear in
  383. the +license+ field of the manifest file for this package. +
  384. The expected format for this variable must comply with the following rules:
  385. ** If different parts of the package are released under different
  386. licenses, then +comma+ separate licenses (e.g. +`LIBFOO_LICENSE =
  387. GPL-2.0+, LGPL-2.1+`+). If there is clear distinction between which
  388. component is licensed under what license, then annotate the license
  389. with that component, between parenthesis (e.g. +`LIBFOO_LICENSE =
  390. GPL-2.0+ (programs), LGPL-2.1+ (libraries)`+).
  391. ** If some licenses are conditioned on a sub-option being enabled, append
  392. the conditional licenses with a comma (e.g.: `FOO_LICENSE += , GPL-2.0+
  393. (programs)`); the infrastructure will internally remove the space before
  394. the comma.
  395. ** If the package is dual licensed, then separate licenses with the
  396. +or+ keyword (e.g. +`LIBFOO_LICENSE = AFL-2.1 or GPL-2.0+`+).
  397. * +LIBFOO_LICENSE_FILES+ is a space-separated list of files in the package
  398. tarball that contain the license(s) under which the package is released.
  399. +make legal-info+ copies all of these files in the +legal-info+ directory.
  400. See xref:legal-info[] for more information.
  401. This variable is optional. If it is not defined, a warning will be produced
  402. to let you know, and +not saved+ will appear in the +license files+ field
  403. of the manifest file for this package.
  404. * +LIBFOO_ACTUAL_SOURCE_TARBALL+ only applies to packages whose
  405. +LIBFOO_SITE+ / +LIBFOO_SOURCE+ pair points to an archive that does
  406. not actually contain source code, but binary code. This a very
  407. uncommon case, only known to apply to external toolchains which come
  408. already compiled, although theoretically it might apply to other
  409. packages. In such cases a separate tarball is usually available with
  410. the actual source code. Set +LIBFOO_ACTUAL_SOURCE_TARBALL+ to the
  411. name of the actual source code archive and Buildroot will download
  412. it and use it when you run +make legal-info+ to collect
  413. legally-relevant material. Note this file will not be downloaded
  414. during regular builds nor by +make source+.
  415. * +LIBFOO_ACTUAL_SOURCE_SITE+ provides the location of the actual
  416. source tarball. The default value is +LIBFOO_SITE+, so you don't
  417. need to set this variable if the binary and source archives are
  418. hosted on the same directory. If +LIBFOO_ACTUAL_SOURCE_TARBALL+ is
  419. not set, it doesn't make sense to define
  420. +LIBFOO_ACTUAL_SOURCE_SITE+.
  421. * +LIBFOO_REDISTRIBUTE+ can be set to +YES+ (default) or +NO+ to indicate if
  422. the package source code is allowed to be redistributed. Set it to +NO+ for
  423. non-opensource packages: Buildroot will not save the source code for this
  424. package when collecting the +legal-info+.
  425. * +LIBFOO_FLAT_STACKSIZE+ defines the stack size of an application built into
  426. the FLAT binary format. The application stack size on the NOMMU architecture
  427. processors can't be enlarged at run time. The default stack size for the
  428. FLAT binary format is only 4k bytes. If the application consumes more stack,
  429. append the required number here.
  430. * +LIBFOO_BIN_ARCH_EXCLUDE+ is a space-separated list of paths (relative
  431. to the target directory) to ignore when checking that the package
  432. installs correctly cross-compiled binaries. You seldom need to set this
  433. variable, unless the package installs binary blobs outside the default
  434. locations, `/lib/firmware`, `/usr/lib/firmware`, `/lib/modules`,
  435. `/usr/lib/modules`, and `/usr/share`, which are automatically excluded.
  436. * +LIBFOO_IGNORE_CVES+ is a space-separated list of CVEs that tells
  437. Buildroot CVE tracking tools which CVEs should be ignored for this
  438. package. This is typically used when the CVE is fixed by a patch in
  439. the package, or when the CVE for some reason does not affect the
  440. Buildroot package. A Makefile comment must always precede the
  441. addition of a CVE to this variable. Example:
  442. +
  443. ----------------------
  444. # 0001-fix-cve-2020-12345.patch
  445. LIBFOO_IGNORE_CVES += CVE-2020-12345
  446. # only when built with libbaz, which Buildroot doesn't support
  447. LIBFOO_IGNORE_CVES += CVE-2020-54321
  448. ----------------------
  449. * [[cpe-id]] +LIBFOO_CPE_ID_*+ variables is a set of variables that allows the
  450. package to define its https://nvd.nist.gov/products/cpe[CPE
  451. identifier]. The available variables are:
  452. +
  453. --
  454. ** +LIBFOO_CPE_ID_VALID+, if set to +YES+, specifies that the default
  455. values for each of the following variables is appropriate, and
  456. generates a valid CPE ID.
  457. ** +LIBFOO_CPE_ID_PREFIX+, specifies the prefix of the CPE identifier,
  458. i.e the first three fields. When not defined, the default value is
  459. +cpe:2.3:a+.
  460. ** +LIBFOO_CPE_ID_VENDOR+, specifies the vendor part of the CPE
  461. identifier. When not defined, the default value is
  462. +<pkgname>_project+.
  463. ** +LIBFOO_CPE_ID_PRODUCT+, specifies the product part of the CPE
  464. identifier. When not defined, the default value is +<pkgname>+.
  465. ** +LIBFOO_CPE_ID_VERSION+, specifies the version part of the CPE
  466. identifier. When not defined the default value is
  467. +$(LIBFOO_VERSION)+.
  468. ** +LIBFOO_CPE_ID_UPDATE+ specifies the _update_ part of the CPE
  469. identifier. When not defined the default value is +*+.
  470. --
  471. +
  472. If any of those variables is defined, then the generic package
  473. infrastructure assumes the package provides valid CPE information. In
  474. this case, the generic package infrastructure will define
  475. +LIBFOO_CPE_ID+.
  476. +
  477. For a host package, if its +LIBFOO_CPE_ID_*+ variables are not
  478. defined, it inherits the value of those variables from the
  479. corresponding target package.
  480. The recommended way to define these variables is to use the following
  481. syntax:
  482. ----------------------
  483. LIBFOO_VERSION = 2.32
  484. ----------------------
  485. Now, the variables that define what should be performed at the
  486. different steps of the build process.
  487. * +LIBFOO_EXTRACT_CMDS+ lists the actions to be performed to extract
  488. the package. This is generally not needed as tarballs are
  489. automatically handled by Buildroot. However, if the package uses a
  490. non-standard archive format, such as a ZIP or RAR file, or has a
  491. tarball with a non-standard organization, this variable allows to
  492. override the package infrastructure default behavior.
  493. * +LIBFOO_CONFIGURE_CMDS+ lists the actions to be performed to
  494. configure the package before its compilation.
  495. * +LIBFOO_BUILD_CMDS+ lists the actions to be performed to
  496. compile the package.
  497. * +HOST_LIBFOO_INSTALL_CMDS+ lists the actions to be performed
  498. to install the package, when the package is a host package. The
  499. package must install its files to the directory given by
  500. +$(HOST_DIR)+. All files, including development files such as
  501. headers should be installed, since other packages might be compiled
  502. on top of this package.
  503. * +LIBFOO_INSTALL_TARGET_CMDS+ lists the actions to be
  504. performed to install the package to the target directory, when the
  505. package is a target package. The package must install its files to
  506. the directory given by +$(TARGET_DIR)+. Only the files required for
  507. 'execution' of the package have to be
  508. installed. Header files, static libraries and documentation will be
  509. removed again when the target filesystem is finalized.
  510. * +LIBFOO_INSTALL_STAGING_CMDS+ lists the actions to be
  511. performed to install the package to the staging directory, when the
  512. package is a target package. The package must install its files to
  513. the directory given by +$(STAGING_DIR)+. All development files
  514. should be installed, since they might be needed to compile other
  515. packages.
  516. * +LIBFOO_INSTALL_IMAGES_CMDS+ lists the actions to be performed to
  517. install the package to the images directory, when the package is a
  518. target package. The package must install its files to the directory
  519. given by +$(BINARIES_DIR)+. Only files that are binary images (aka
  520. images) that do not belong in the +TARGET_DIR+ but are necessary
  521. for booting the board should be placed here. For example, a package
  522. should utilize this step if it has binaries which would be similar
  523. to the kernel image, bootloader or root filesystem images.
  524. * +LIBFOO_INSTALL_INIT_SYSV+, +LIBFOO_INSTALL_INIT_OPENRC+ and
  525. +LIBFOO_INSTALL_INIT_SYSTEMD+ list the actions to install init
  526. scripts either for the systemV-like init systems (busybox,
  527. sysvinit, etc.), openrc or for the systemd units. These commands
  528. will be run only when the relevant init system is installed (i.e.
  529. if systemd is selected as the init system in the configuration,
  530. only +LIBFOO_INSTALL_INIT_SYSTEMD+ will be run). The only exception
  531. is when openrc is chosen as init system and +LIBFOO_INSTALL_INIT_OPENRC+
  532. has not been set, in such situation +LIBFOO_INSTALL_INIT_SYSV+ will
  533. be called, since openrc supports sysv init scripts.
  534. When systemd is used as the init system, buildroot will automatically enable
  535. all services using the +systemctl preset-all+ command in the final phase of
  536. image building. You can add preset files to prevent a particular unit from
  537. being automatically enabled by buildroot.
  538. * +LIBFOO_HELP_CMDS+ lists the actions to print the package help, which
  539. is included to the main +make help+ output. These commands can print
  540. anything in any format.
  541. This is seldom used, as packages rarely have custom rules. *Do not use
  542. this variable*, unless you really know that you need to print help.
  543. * +LIBFOO_LINUX_CONFIG_FIXUPS+ lists the Linux kernel configuration
  544. options that are needed to build and use this package, and without
  545. which the package is fundamentally broken. This shall be a set of
  546. calls to one of the kconfig tweaking option: `KCONFIG_ENABLE_OPT`,
  547. `KCONFIG_DISABLE_OPT`, or `KCONFIG_SET_OPT`.
  548. This is seldom used, as package usually have no strict requirements on
  549. the kernel options.
  550. The preferred way to define these variables is:
  551. ----------------------
  552. define LIBFOO_CONFIGURE_CMDS
  553. action 1
  554. action 2
  555. action 3
  556. endef
  557. ----------------------
  558. In the action definitions, you can use the following variables:
  559. * +$(LIBFOO_PKGDIR)+ contains the path to the directory containing the
  560. +libfoo.mk+ and +Config.in+ files. This variable is useful when it is
  561. necessary to install a file bundled in Buildroot, like a runtime
  562. configuration file, a splashscreen image...
  563. * +$(@D)+, which contains the directory in which the package source
  564. code has been uncompressed.
  565. * +$(LIBFOO_DL_DIR)+ contains the path to the directory where all the downloads
  566. made by Buildroot for +libfoo+ are stored in.
  567. * +$(TARGET_CC)+, +$(TARGET_LD)+, etc. to get the target
  568. cross-compilation utilities
  569. * +$(TARGET_CROSS)+ to get the cross-compilation toolchain prefix
  570. * Of course the +$(HOST_DIR)+, +$(STAGING_DIR)+ and +$(TARGET_DIR)+
  571. variables to install the packages properly. Those variables point to
  572. the global _host_, _staging_ and _target_ directories, unless
  573. _per-package directory_ support is used, in which case they point to
  574. the current package _host_, _staging_ and _target_ directories. In
  575. both cases, it doesn't make any difference from the package point of
  576. view: it should simply use +HOST_DIR+, +STAGING_DIR+ and
  577. +TARGET_DIR+. See xref:top-level-parallel-build[] for more details
  578. about _per-package directory_ support.
  579. Finally, you can also use hooks. See xref:hooks[] for more information.