ref-classes.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <!DOCTYPE appendix PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  2. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
  3. <appendix id='ref-classes'>
  4. <title>Reference: Classes</title>
  5. <para>
  6. Class files are used to abstract common functionality and share it amongst multiple
  7. <filename class="extension">.bb</filename> files. Any metadata usually found in a
  8. <filename class="extension">.bb</filename> file can also be placed in a class
  9. file. Class files are identified by the extension
  10. <filename class="extension">.bbclass</filename> and are usually placed
  11. in a <filename class="directory">classes/</filename> directory beneath the
  12. <filename class="directory">meta*/</filename> directory or the directory pointed
  13. by BUILDDIR (e.g. <filename class="directory">build/</filename>)in the same way as
  14. <filename class="extension">.conf</filename> files in the <filename
  15. class="directory">conf</filename> directory. Class files are searched for
  16. in BBPATH in the same was as <filename class="extension">.conf</filename> files too.
  17. </para>
  18. <para>
  19. In most cases inheriting the class is enough to enable its features, although
  20. for some classes you may need to set variables and/or override some of the
  21. default behaviour.
  22. </para>
  23. <section id='ref-classes-base'>
  24. <title>The base class - <filename>base.bbclass</filename></title>
  25. <para>
  26. The base class is special in that every <filename class="extension">.bb</filename>
  27. file inherits it automatically. It contains definitions of standard basic
  28. tasks such as fetching, unpacking, configuring (empty by default), compiling
  29. (runs any Makefile present), installing (empty by default) and packaging
  30. (empty by default). These are often overridden or extended by other classes
  31. such as <filename>autotools.bbclass</filename> or
  32. <filename>package.bbclass</filename>. The class also contains some commonly
  33. used functions such as <function>oe_runmake</function>.
  34. </para>
  35. </section>
  36. <section id='ref-classes-autotools'>
  37. <title>Autotooled Packages - <filename>autotools.bbclass</filename></title>
  38. <para>
  39. Autotools (autoconf, automake, libtool) brings standardisation and this
  40. class aims to define a set of tasks (configure, compile etc.) that will
  41. work for all autotooled packages. It should usualy be enough to define
  42. a few standard variables as documented in the <link
  43. linkend='usingpoky-extend-addpkg-autotools'>simple autotools
  44. example</link> section and then simply "inherit autotools". This class
  45. can also work with software that emulates autotools.
  46. </para>
  47. <para>
  48. It's useful to have some idea on how the tasks defined by this class work
  49. and what they do behind the scenes.
  50. </para>
  51. <itemizedlist>
  52. <listitem>
  53. <para>
  54. 'do_configure' regenearates the configure script (using autoreconf) and
  55. then launches it with a standard set of arguments used during
  56. cross-compilation. Additional parameters can be passed to
  57. <command>configure</command> through the <glossterm><link
  58. linkend='var-EXTRA_OECONF'>EXTRA_OECONF</link></glossterm> variable.
  59. </para>
  60. </listitem>
  61. <listitem>
  62. <para>
  63. 'do_compile' runs <command>make</command> with arguments specifying
  64. the compiler and linker. Additional arguments can be passed through
  65. the <glossterm><link linkend='var-EXTRA_OEMAKE'>EXTRA_OEMAKE</link>
  66. </glossterm> variable.
  67. </para>
  68. </listitem>
  69. <listitem>
  70. <para>
  71. 'do_install' runs <command>make install</command> passing a DESTDIR
  72. option taking its value from the standard <glossterm><link
  73. linkend='var-DESTDIR'>DESTDIR</link></glossterm> variable.
  74. </para>
  75. </listitem>
  76. </itemizedlist>
  77. </section>
  78. <section id='ref-classes-update-alternatives'>
  79. <title>Alternatives - <filename>update-alternatives.bbclass</filename></title>
  80. <para>
  81. Several programs can fulfill the same or similar function and
  82. they can be installed with the same name. For example the <command>ar</command>
  83. command is available from the "busybox", "binutils" and "elfutils" packages.
  84. This class handles the renaming of the binaries so multiple packages
  85. can be installed which would otherwise conflict and yet the
  86. <command>ar</command> command still works regardless of which are installed
  87. or subsequently removed. It renames the conflicting binary in each package
  88. and symlinks the highest priority binary during installation or removal
  89. of packages.
  90. Four variables control this class:
  91. </para>
  92. <variablelist>
  93. <varlistentry>
  94. <term>ALTERNATIVE_NAME</term>
  95. <listitem>
  96. <para>
  97. Name of binary which will be replaced (<command>ar</command> in this example)
  98. </para>
  99. </listitem>
  100. </varlistentry>
  101. <varlistentry>
  102. <term>ALTERNATIVE_LINK</term>
  103. <listitem>
  104. <para>
  105. Path to resulting binary ("/bin/ar" in this example)
  106. </para>
  107. </listitem>
  108. </varlistentry>
  109. <varlistentry>
  110. <term>ALTERNATIVE_PATH</term>
  111. <listitem>
  112. <para>
  113. Path to real binary ("/usr/bin/ar.binutils" in this example)
  114. </para>
  115. </listitem>
  116. </varlistentry>
  117. <varlistentry>
  118. <term>ALTERNATIVE_PRIORITY</term>
  119. <listitem>
  120. <para>
  121. Priority of binary, the version with the most features should have the highest priority
  122. </para>
  123. </listitem>
  124. </varlistentry>
  125. </variablelist>
  126. <para>
  127. Currently, only one binary per package is supported.
  128. </para>
  129. </section>
  130. <section id='ref-classes-update-rc.d'>
  131. <title>Initscripts - <filename>update-rc.d.bbclass</filename></title>
  132. <para>
  133. This class uses update-rc.d to safely install an initscript on behalf of
  134. the package. Details such as making sure the initscript is stopped before
  135. a package is removed and started when the package is installed are taken
  136. care of. Three variables control this class,
  137. <link linkend='var-INITSCRIPT_PACKAGES'>INITSCRIPT_PACKAGES</link>,
  138. <link linkend='var-INITSCRIPT_NAME'>INITSCRIPT_NAME</link> and
  139. <link linkend='var-INITSCRIPT_PARAMS'>INITSCRIPT_PARAMS</link>. See the
  140. links for details.
  141. </para>
  142. </section>
  143. <section id='ref-classes-binconfig'>
  144. <title>Binary config scripts - <filename>binconfig.bbclass</filename></title>
  145. <para>
  146. Before pkg-config had become widespread, libraries shipped shell
  147. scripts to give information about the libraries and include paths needed
  148. to build software (usually named 'LIBNAME-config'). This class assists
  149. any recipe using such scripts.
  150. </para>
  151. <para>
  152. During staging Bitbake installs such scripts into the <filename
  153. class="directory">sysroots/</filename> directory. It also changes all
  154. paths to point into the <filename class="directory">sysroots/</filename>
  155. directory so all builds which use the script will use the correct
  156. directories for the cross compiling layout.
  157. </para>
  158. </section>
  159. <section id='ref-classes-debian'>
  160. <title>Debian renaming - <filename>debian.bbclass</filename></title>
  161. <para>
  162. This class renames packages so that they follow the Debian naming
  163. policy, i.e. 'glibc' becomes 'libc6' and 'glibc-devel' becomes
  164. 'libc6-dev'.
  165. </para>
  166. </section>
  167. <section id='ref-classes-pkgconfig'>
  168. <title>Pkg-config - <filename>pkgconfig.bbclass</filename></title>
  169. <para>
  170. Pkg-config brought standardisation and this class aims to make its
  171. integration smooth for all libraries which make use of it.
  172. </para>
  173. <para>
  174. During staging Bitbake installs pkg-config data into the <filename
  175. class="directory">sysroots/</filename> directory. By making use of
  176. sysroot functionality within pkgconfig this class no longer has to
  177. manipulate the files.
  178. </para>
  179. </section>
  180. <section id='ref-classes-src-distribute'>
  181. <title>Distribution of sources - <filename>src_distribute_local.bbclass</filename></title>
  182. <para>
  183. Many software licenses require providing the sources for compiled
  184. binaries. To simplify this process two classes were created:
  185. <filename>src_distribute.bbclass</filename> and
  186. <filename>src_distribute_local.bbclass</filename>.
  187. </para>
  188. <para>
  189. Result of their work are <filename class="directory">tmp/deploy/source/</filename>
  190. subdirs with sources sorted by <glossterm><link linkend='var-LICENSE'>LICENSE</link>
  191. </glossterm> field. If recipe lists few licenses (or has entries like "Bitstream Vera") source archive is put in each
  192. license dir.
  193. </para>
  194. <para>
  195. Src_distribute_local class has three modes of operating:
  196. </para>
  197. <itemizedlist>
  198. <listitem><para>copy - copies the files to the distribute dir</para></listitem>
  199. <listitem><para>symlink - symlinks the files to the distribute dir</para></listitem>
  200. <listitem><para>move+symlink - moves the files into distribute dir, and symlinks them back</para></listitem>
  201. </itemizedlist>
  202. </section>
  203. <section id='ref-classes-perl'>
  204. <title>Perl modules - <filename>cpan.bbclass</filename></title>
  205. <para>
  206. Recipes for Perl modules are simple - usually needs only
  207. pointing to source archive and inheriting of proper bbclass.
  208. Building is split into two methods dependly on method used by
  209. module authors.
  210. </para>
  211. <para>
  212. Modules which use old Makefile.PL based build system require
  213. using of <filename>cpan.bbclass</filename> in their recipes.
  214. </para>
  215. <para>
  216. Modules which use Build.PL based build system require
  217. using of <filename>cpan_build.bbclass</filename> in their recipes.
  218. </para>
  219. </section>
  220. <section id='ref-classes-distutils'>
  221. <title>Python extensions - <filename>distutils.bbclass</filename></title>
  222. <para>
  223. Recipes for Python extensions are simple - they usually only
  224. require pointing to the source archive and inheriting the proper
  225. bbclasses.
  226. Building is split into two methods depending on the build method
  227. used by the module authors.
  228. </para>
  229. <para>
  230. Extensions which use autotools based build system require use
  231. of autotools and distutils-base bbclasses in their recipes.
  232. </para>
  233. <para>
  234. Extensions which use distutils build system require use
  235. of <filename>distutils.bbclass</filename> in their recipes.
  236. </para>
  237. </section>
  238. <section id='ref-classes-devshell'>
  239. <title>Developer Shell - <filename>devshell.bbclass</filename></title>
  240. <para>
  241. This class adds the devshell task. Its usually up to distribution policy
  242. to include this class (Poky does). See the <link
  243. linkend='platdev-appdev-devshell'>developing with 'devshell' section</link>
  244. for more information about using devshell.
  245. </para>
  246. </section>
  247. <section id='ref-classes-package'>
  248. <title>Packaging - <filename>package*.bbclass</filename></title>
  249. <para>
  250. The packaging classes add support for generating packages from a builds
  251. output. The core generic functionality is in
  252. <filename>package.bbclass</filename>, code specific to particular package
  253. types is contained in various sub classes such as
  254. <filename>package_deb.bbclass</filename>, <filename>package_ipk.bbclass</filename>
  255. and <filename>package_rpm.bbclass</filename>. Most users will
  256. want one or more of these classes and this is controlled by the <glossterm>
  257. <link linkend='var-PACKAGE_CLASSES'>PACKAGE_CLASSES</link></glossterm>
  258. variable. The first class listed in this variable will be used for image
  259. generation. Since images are generated from packages a packaging class is
  260. needed to enable image generation.
  261. </para>
  262. </section>
  263. <section id='ref-classes-kernel'>
  264. <title>Building kernels - <filename>kernel.bbclass</filename></title>
  265. <para>
  266. This class handles building of Linux kernels and the class contains code to know how to build both 2.4 and 2.6 kernel trees. All needed headers are
  267. staged into <glossterm><link
  268. linkend='var-STAGING_KERNEL_DIR'>STAGING_KERNEL_DIR</link></glossterm>
  269. directory to allow building of out-of-tree modules using <filename>module.bbclass</filename>.
  270. </para>
  271. <para>
  272. This means that each kernel module built is packaged separately and inter-module dependencies are
  273. created by parsing the <command>modinfo</command> output. If all modules are
  274. required then installing the "kernel-modules" package will install all
  275. packages with modules and various other kernel packages such as "kernel-vmlinux".
  276. </para>
  277. <para>
  278. Various other classes are used by the kernel and module classes internally including
  279. <filename>kernel-arch.bbclass</filename>, <filename>module_strip.bbclass</filename>,
  280. <filename>module-base.bbclass</filename> and <filename>linux-kernel-base.bbclass</filename>.
  281. </para>
  282. </section>
  283. <section id='ref-classes-image'>
  284. <title>Creating images - <filename>image.bbclass</filename> and <filename>rootfs*.bbclass</filename></title>
  285. <para>
  286. Those classes add support for creating images in many formats. First the
  287. rootfs is created from packages by one of the <filename>rootfs_*.bbclass</filename>
  288. files (depending on package format used) and then image is created.
  289. The <glossterm><link
  290. linkend='var-IMAGE_FSTYPES'>IMAGE_FSTYPES</link></glossterm>
  291. variable controls which types of image to generate.
  292. The list of packages to install into the image is controlled by the
  293. <glossterm><link
  294. linkend='var-IMAGE_INSTALL'>IMAGE_INSTALL</link></glossterm>
  295. variable.
  296. </para>
  297. </section>
  298. <section id='ref-classes-sanity'>
  299. <title>Host System sanity checks - <filename>sanity.bbclass</filename></title>
  300. <para>
  301. This class checks prerequisite software is present to
  302. notify the users problems that will affect their build. It also
  303. performs basic checks of the user configuration from local.conf to
  304. prevent common mistakes resulting in build failures. It's usually up to
  305. distribution policy whether to include this class (Poky does).
  306. </para>
  307. </section>
  308. <section id='ref-classes-insane'>
  309. <title>Generated output quality assurance checks - <filename>insane.bbclass</filename></title>
  310. <para>
  311. This class adds a step to package generation which sanity checks the
  312. packages generated by Poky. There are an ever increasing range of checks
  313. it performs, checking for common problems which break builds/packages/images,
  314. see the bbclass file for more information. It's usually up to distribution
  315. policy whether to include this class (Poky does).
  316. </para>
  317. </section>
  318. <section id='ref-classes-siteinfo'>
  319. <title>Autotools configuration data cache - <filename>siteinfo.bbclass</filename></title>
  320. <para>
  321. Autotools can require tests which have to execute on the target hardware.
  322. Since this isn't possible in general when cross compiling, siteinfo is
  323. used to provide cached test results so these tests can be skipped over but
  324. the correct values used. The <link linkend='structure-meta-site'>meta/site directory</link>
  325. contains test results sorted into different categories like architecture, endianess and
  326. the libc used. Siteinfo provides a list of files containing data relevant to
  327. the current build in the <glossterm><link linkend='var-CONFIG_SITE'>CONFIG_SITE
  328. </link></glossterm> variable which autotools will automatically pick up.
  329. </para>
  330. <para>
  331. The class also provides variables like <glossterm><link
  332. linkend='var-SITEINFO_ENDIANESS'>SITEINFO_ENDIANESS</link></glossterm>
  333. and <glossterm><link linkend='var-SITEINFO_BITS'>SITEINFO_BITS</link>
  334. </glossterm> which can be used elsewhere in the metadata.
  335. </para>
  336. <para>
  337. This class is included from <filename>base.bbclass</filename> and is hence always active.
  338. </para>
  339. </section>
  340. <section id='ref-classes-others'>
  341. <title>Other Classes</title>
  342. <para>
  343. Only the most useful/important classes are covered here but there are
  344. others, see the <filename class="directory">meta/classes</filename> directory for the rest.
  345. </para>
  346. </section>
  347. <!-- Undocumented classes are:
  348. base_srpm.bbclass
  349. bootimg.bbclass
  350. ccache.inc
  351. ccdv.bbclass
  352. cmake.bbclass
  353. cml1.bbclass
  354. cross.bbclass
  355. flow-lossage.bbclass
  356. gconf.bbclass
  357. gettext.bbclass
  358. gnome.bbclass
  359. gtk-icon-cache.bbclass
  360. icecc.bbclass
  361. lib_package.bbclass
  362. mirrors.bbclass
  363. mozilla.bbclass
  364. multimachine.bbclass
  365. native.bbclass
  366. oelint.bbclass
  367. patch.bbclass
  368. patcher.bbclass
  369. pkg_distribute.bbclass
  370. pkg_metainfo.bbclass
  371. poky.bbclass
  372. rm_work.bbclass
  373. rpm_core.bbclass
  374. scons.bbclass
  375. sdk.bbclass
  376. sdl.bbclass
  377. sip.bbclass
  378. sourcepkg.bbclass
  379. srec.bbclass
  380. syslinux.bbclass
  381. tinderclient.bbclass
  382. tmake.bbclass
  383. utils.bbclass
  384. xfce.bbclass
  385. xlibs.bbclass
  386. -->
  387. </appendix>
  388. <!--
  389. vim: expandtab tw=80 ts=4
  390. -->