buildroot.html 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093
  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <title>Buildroot - Usage and documentation</title>
  7. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  8. <link rel="stylesheet" type="text/css" href="stylesheet.css" />
  9. </head>
  10. <body>
  11. <div class="main">
  12. <div class="titre">
  13. <h1>Buildroot</h1>
  14. </div>
  15. <p><a href="http://buildroot.net/">Buildroot</a>
  16. usage and documentation by Thomas Petazzoni. Contributions from
  17. Karsten Kruse, Ned Ludd, Martin Herren and others. </p>
  18. <ul>
  19. <li><a href="#about">About Buildroot</a></li>
  20. <li><a href="#download">Obtaining Buildroot</a></li>
  21. <li><a href="#using">Using Buildroot</a></li>
  22. <li><a href="#custom_targetfs">Customizing the generated target filesystem</a></li>
  23. <li><a href="#custom_busybox">Customizing the Busybox
  24. configuration</a></li>
  25. <li><a href="#custom_uclibc">Customizing the uClibc
  26. configuration</a></li>
  27. <li><a href="#rebuilding_packages">Understanding how to rebuild packages</a></li>
  28. <li><a href="#buildroot_innards">How Buildroot works</a></li>
  29. <li><a href="#using_toolchain">Using the uClibc toolchain
  30. outside Buildroot</a></li>
  31. <li><a href="#external_toolchain">Use an external toolchain</a></li>
  32. <li><a href="#downloaded_packages">Location of downloaded packages</a>
  33. </li>
  34. <li><a href="#add_software">Extending Buildroot with more
  35. Software</a></li>
  36. <li><a href="#board_support">Creating your own board support</a></li>
  37. <li><a href="#links">Resources</a></li>
  38. </ul>
  39. <h2><a name="about" id="about"></a>About Buildroot</h2>
  40. <p>Buildroot is a set of Makefiles and patches that allow to
  41. easily generate a cross-compilation toolchain, a root filesystem
  42. and a Linux kernel image for your target. Buildroot can be used
  43. for either one, two or all of these options, independently.</p>
  44. <p>Buildroot is useful mainly for people working with embedded systems.
  45. Embedded systems often use processors that are not the regular x86
  46. processors everyone is used to have on his PC. It can be PowerPC
  47. processors, MIPS processors, ARM processors, etc. </p>
  48. <p>A compilation toolchain is the set of tools that allows to
  49. compile code for your system. It consists of a compiler (in our
  50. case, <code>gcc</code>), binary utils like assembler and linker
  51. (in our case, <code>binutils</code>) and a C standard library (for
  52. example <a href="http://www.gnu.org/software/libc/libc.html">GNU
  53. Libc</a>, <a href="http://www.uclibc.org/">uClibc</a> or <a
  54. href="http://www.fefe.de/dietlibc/">dietlibc</a>). The system
  55. installed on your development station certainly already has a
  56. compilation toolchain that you can use to compile application that
  57. runs on your system. If you're using a PC, your compilation
  58. toolchain runs on an x86 processor and generates code for a x86
  59. processor. Under most Linux systems, the compilation toolchain
  60. uses the GNU libc as C standard library. This compilation
  61. toolchain is called the &quot;host compilation toolchain&quot;, and more
  62. generally, the machine on which it is running, and on which you're
  63. working is called the &quot;host system&quot;. The compilation toolchain
  64. is provided by your distribution, and Buildroot has nothing to do
  65. with it. </p>
  66. <p>As said above, the compilation toolchain that comes with your system
  67. runs and generates code for the processor of your host system. As your
  68. embedded system has a different processor, you need a cross-compilation
  69. toolchain: it's a compilation toolchain that runs on your host system but
  70. that generates code for your target system (and target processor). For
  71. example, if your host system uses x86 and your target system uses ARM, the
  72. regular compilation toolchain of your host runs on x86 and generates code
  73. for x86, while the cross-compilation toolchain runs on x86 and generates
  74. code for ARM. </p>
  75. <p>Even if your embedded system uses a x86 processor, you might interested
  76. in Buildroot, for two reasons:</p>
  77. <ul>
  78. <li>The compilation toolchain of your host certainly uses the GNU Libc
  79. which is a complete but huge C standard library. Instead of using GNU
  80. Libc on your target system, you can use uClibc which is a tiny C standard
  81. library. If you want to use this C library, then you need a compilation
  82. toolchain to generate binaries linked with it. Buildroot can do it for
  83. you. </li>
  84. <li>Buildroot automates the building of a root filesystem with all needed
  85. tools like busybox. It makes it much easier than doing it by hand. </li>
  86. </ul>
  87. <p>You might wonder why such a tool is needed when you can compile
  88. <code>gcc</code>, <code>binutils</code>, uClibc and all the tools by hand.
  89. Of course, doing so is possible. But dealing with all configure options,
  90. with all problems of every <code>gcc</code> or <code>binutils</code>
  91. version it very time-consuming and uninteresting. Buildroot automates this
  92. process through the use of Makefiles, and has a collection of patches for
  93. each <code>gcc</code> and <code>binutils</code> version to make them work
  94. on most architectures. </p>
  95. <p>Moreover, Buildroot provides an infrastructure for reproducing
  96. the build process of your embedded root filesystem. Being able to
  97. reproduce the build process will be useful when a component needs
  98. to be patched or updated, or when another person is supposed to
  99. take over the project.</p>
  100. <h2><a name="download" id="download"></a>Obtaining Buildroot</h2>
  101. <p>Buildroot releases are made approximately every 3
  102. months. Direct Git access and daily snapshots are also
  103. available if you want more bleeding edge.</p>
  104. <p>Releases are available at <a
  105. href="http://buildroot.net/downloads/">http://buildroot.net/downloads/</a>.</p>
  106. <p>The latest snapshot is always available at <a
  107. href="http://buildroot.net/downloads/snapshots/buildroot-snapshot.tar.bz2">http://buildroot.net/downloads/snapshots/buildroot-snapshot.tar.bz2</a>,
  108. and previous snapshots are also available at <a
  109. href="http://buildroot.net/downloads/snapshots/">http://buildroot.net/downloads/snapshots/</a>. </p>
  110. <p>To download Buildroot using Git, you can simply follow
  111. the rules described on the &quot;Accessing Git&quot;-page (<a href=
  112. "http://buildroot.net/git.html">http://buildroot.net/git.html</a>)
  113. of the Buildroot website (<a href=
  114. "http://buildroot.net">http://buildroot.net</a>), and download
  115. <code>buildroot</code> from Git. For the impatient, here's a quick
  116. recipe:</p>
  117. <pre>
  118. $ git clone git://git.buildroot.net/buildroot
  119. </pre>
  120. <h2><a name="using" id="using"></a>Using Buildroot</h2>
  121. <p>Buildroot has a nice configuration tool similar to the one you can find
  122. in the Linux Kernel (<a href=
  123. "http://www.kernel.org/">http://www.kernel.org/</a>) or in Busybox
  124. (<a href="http://www.busybox.org/">http://www.busybox.org/</a>). Note that
  125. you can build everything as a normal user. There is no need to be root to
  126. configure and use Buildroot. The first step is to run the configuration
  127. assistant:</p>
  128. <pre>
  129. $ make menuconfig
  130. </pre>
  131. <p>to run the curses-based configurator, or</p>
  132. <pre>
  133. $ make xconfig
  134. </pre>
  135. <p>to run the Qt3-based configurator. On Debian-like systems, the
  136. <code>libncurses5-dev</code> package is required to use the
  137. <i>menuconfig</i> interface, and the <code>libqt3-mt-dev</code> is
  138. required to use the <i>xconfig</i> interface.</p>
  139. <p>For each entry of the configuration tool, you can find associated help
  140. that describes the purpose of the entry. </p>
  141. <p>Once everything is configured, the configuration tool has generated a
  142. <code>.config</code> file that contains the description of your
  143. configuration. It will be used by the Makefiles to do what's needed. </p>
  144. <p>Let's go:</p>
  145. <pre>
  146. $ make
  147. </pre>
  148. <p>This command will download, configure and compile all the
  149. selected tools, and finally generate a toolchain, a root
  150. filesystem image and a kernel image (or only one of these
  151. elements, depending on the configuration).</p>
  152. <p>Buildroot output is stored in a single directory,
  153. <code>output/</code>. This directory contains several
  154. subdirectories:</p>
  155. <ul>
  156. <li><code>images/</code> where all the images (kernel image,
  157. bootloader and root filesystem images) are stored.</li>
  158. <li><code>build/</code> where all the components are built
  159. (tools needed to run Buildroot on the host and packages compiled
  160. for the target). The <code>build/</code> directory contains one
  161. subdirectory for each of these components. The toolchain
  162. components are however built in a separate directory.</li>
  163. <li><code>staging/</code> which contains a hierarchy similar to
  164. a root filesystem hierarchy. This directory contains the
  165. installation of cross-compilation toolchain and all the
  166. userspace packages selected for the target. However, this
  167. directory is <i>not</i> intended to be the root filesystem for
  168. the target: it contains a lot of development files, unstripped
  169. binaries and libraries, that make it far too big for an embedded
  170. system.</li>
  171. <li><code>target/<code> which contains the root filesystem for
  172. the target. Only the necessary files to run the libraries and
  173. applications are installed in this directory. However,
  174. <code>target/dev/</code> doesn't contain the device files, as
  175. creating device files requires the root access. The device files
  176. only exist in the root filesystem image produced by
  177. Buildroot.</li>
  178. <li><code>host/</code> contains the installation of tools
  179. compiled for the host that are needed for the proper execution
  180. of Buildroot.</li>
  181. <li><code>toolchain/</code> contains the build directories for
  182. the various components of the cross-compilation toolchain.</li>
  183. </ul>
  184. <h3><a name="offline_builds" id="offline_builds"></a>
  185. Offline builds</h3>
  186. <p>If you intend to do an offline-build and just want to download
  187. all sources that you previously selected in the configurator
  188. (<i>menuconfig</i> or <i>xconfig</i>) then issue:</p>
  189. <pre>
  190. $ make source
  191. </pre>
  192. <p>You can now disconnect or copy the content of your <code>dl</code>
  193. directory to the build-host. </p>
  194. <h3><a name="building_out_of_tree" id="building_out_of_tree"></a>
  195. Building out-of-tree</h3>
  196. <p>Buildroot supports building out of tree with a syntax similar
  197. to the Linux kernel. To use it, add O=&lt;directory&gt; to the
  198. make command line, E.G.:</p>
  199. <pre>
  200. $ make O=/tmp/build
  201. </pre>
  202. <p>And all the output files will be located under
  203. <code>/tmp/build</code>.</p>
  204. <h3><a name="environment_variables" id="environment_variables"></a>
  205. Environment variables</h3>
  206. <p>Buildroot optionally honors some environment variables that are passed
  207. to <code>make</code> :</p>
  208. <ul>
  209. <li><code>HOSTCXX</code>, the host C++ compiler to use</li>
  210. <li><code>HOSTCC</code>, the host C compiler to use</li>
  211. <li><code>UCLIBC_CONFIG_FILE=&lt;path/to/.config&gt;</code>, path
  212. to the uClibc configuration file to use to compile uClibc if an
  213. internal toolchain is selected</li>
  214. <li><code>BUSYBOX_CONFIG_FILE=&lt;path/to/.config&gt;</code>, path
  215. to the Busybox configuration file</li>
  216. <li><code>BUILDROOT_COPYTO</code>, an additional location at which
  217. the binary images of the root filesystem, kernel, etc. built by
  218. Buildroot are copied</li>
  219. <li><code>BUILDROOT_DL_DIR</code> to override the directory in
  220. which Buildroot stores/retrieves downloaded files</li>
  221. </ul>
  222. <p>An example that uses config files located in the toplevel directory and
  223. in your $HOME:</p>
  224. <pre>
  225. $ make UCLIBC_CONFIG_FILE=uClibc.config BUSYBOX_CONFIG_FILE=$HOME/bb.config
  226. </pre>
  227. <p>If you want to use a compiler other than the default <code>gcc</code>
  228. or <code>g++</code> for building helper-binaries on your host, then do</p>
  229. <pre>
  230. $ make HOSTCXX=g++-4.3-HEAD HOSTCC=gcc-4.3-HEAD
  231. </pre>
  232. <p>If you want the result of your build to be copied to another directory
  233. like /tftpboot for downloading to a board using tftp, then you
  234. can use BUILDROOT_COPYTO to specify your location</p>
  235. <p>Typically, this is set in your ~/.bashrc file
  236. <pre>
  237. $ export BUILDROOT_COPYTO=/tftpboot
  238. </pre>
  239. <h2><a name="custom_targetfs" id="custom_targetfs"></a>Customizing the
  240. generated target filesystem</h2>
  241. <p>There are a few ways to customize the resulting target filesystem:</p>
  242. <ul>
  243. <li>Customize the target filesystem directly, and rebuild the image. The
  244. target filesystem is available under <code>output/target/</code>.
  245. You can simply make your changes here, and run make afterwards, which will
  246. rebuild the target filesystem image. This method allows to do everything
  247. on the target filesystem, but if you decide to completely rebuild your
  248. toolchain and tools, these changes will be lost. </li>
  249. <li>Customize the target filesystem skeleton, available under
  250. <code>target/generic/target_skeleton/</code>. You can customize
  251. configuration files or other stuff here. However, the full file hierarchy
  252. is not yet present, because it's created during the compilation process.
  253. So you can't do everything on this target filesystem skeleton, but
  254. changes to it remain even if you completely rebuild the cross-compilation
  255. toolchain and the tools. <br />
  256. You can also customize the <code>target/generic/device_table.txt</code>
  257. file which is used by the tools that generate the target filesystem image
  258. to properly set permissions and create device nodes. The
  259. <code>target/generic/skel.tar.gz</code> file contains the main
  260. directories of a root filesystem and there is no obvious reason for which
  261. it should be changed. These main directories are in an tarball inside of
  262. inside the skeleton because it contains symlinks that would be broken
  263. otherwise. <br />
  264. These customizations are deployed into
  265. <code>output/target/</code> just before the actual image
  266. is made. So simply rebuilding the image by running
  267. make should propagate any new changes to the image. </li>
  268. <li>Add support for your own target in Buildroot so that you
  269. have your own target skeleton, see <a href="#board_support">this
  270. section</a> for details</li>
  271. <li>In Buildroot configuration, you can specify the path to a
  272. post-build script that gets called <i>after</i> Buildroot built
  273. all the selected software, but <i>before</i> the the rootfs
  274. packages are assembled. The destination root filesystem folder
  275. is given as first argument to this script, and this script can
  276. then be used to copy programs, static data or any other needed
  277. file to your target filesystem.<br/>You should, however, use
  278. that feature with care. Whenever you find that a certain package
  279. generates wrong or unneeded files, you should rather fix than
  280. package than working around it with a cleanup script.</li>
  281. <li>A special package, <i>customize</i>, stored in
  282. <code>package/customize</code> can be used. You can put all the
  283. files that you want to see in the final target root filesystem
  284. in <code>package/customize/source</code>, and then enable this
  285. special package from the configuration system.</li>
  286. </ul>
  287. <h2><a name="custom_busybox" id="custom_busybox"></a>Customizing the
  288. Busybox configuration</h2>
  289. <p><a href="http://www.busybox.net/">Busybox</a> is very configurable, and
  290. you may want to customize it. You can
  291. follow these simple steps to do it. It's not an optimal way, but it's
  292. simple and it works. </p>
  293. <ol>
  294. <li>Make a first compilation of buildroot with busybox without trying to
  295. customize it. </li>
  296. <li>Invoke <code>make busybox-menuconfig</code>.
  297. The nice configuration tool appears and you can
  298. customize everything. </li>
  299. <li>Run the compilation of buildroot again. </li>
  300. </ol>
  301. <p>Otherwise, you can simply change the
  302. <code>package/busybox/busybox-&lt;version&gt;.config</code> file if you
  303. know the options you want to change without using the configuration tool.
  304. </p>
  305. <p>If you want to use an existing config file for busybox, then see
  306. section <a href="#environment_variables">environment variables</a>. </p>
  307. <h2><a name="custom_uclibc" id="custom_uclibc"></a>Customizing the uClibc
  308. configuration</h2>
  309. <p>Just like <a href="#custom_busybox">BusyBox</a>, <a
  310. href="http://www.uclibc.org/">uClibc</a> offers a lot of
  311. configuration options. They allow to select various
  312. functionalities, depending on your needs and limitations. </p>
  313. <p>The easiest way to modify the configuration of uClibc is to
  314. follow these steps :</p>
  315. <ol>
  316. <li>Make a first compilation of buildroot without trying to
  317. customize uClibc. </li>
  318. <li>Invoke <code>make uclibc-menuconfig</code>.
  319. The nice configuration assistant, similar to
  320. the one used in the Linux Kernel or in Buildroot appears. Make
  321. your configuration as appropriate. </li>
  322. <li>Copy the <code>.config</code> file to
  323. <code>toolchain/uClibc/uClibc.config</code> or
  324. <code>toolchain/uClibc/uClibc.config-locale</code>. The former
  325. is used if you haven't selected locale support in Buildroot
  326. configuration, and the latter is used if you have selected
  327. locale support. </li>
  328. <li>Run the compilation of Buildroot again</li>
  329. </ol>
  330. <p>Otherwise, you can simply change
  331. <code>toolchain/uClibc/uClibc.config</code> or
  332. <code>toolchain/uClibc/uClibc.config-locale</code> without running
  333. the configuration assistant. </p>
  334. <p>If you want to use an existing config file for uclibc, then see
  335. section <a href="#environment_variables">environment variables</a>. </p>
  336. <h2><a name="#rebuilding_packages"
  337. id="rebuilding_packages">Understanding how to rebuild
  338. packages</a></h2>
  339. <p>One of the most common question and issue about Buildroot
  340. encountered by users is how to rebuild a given package or how to
  341. remove a package without rebuilding everything from scratch.</p>
  342. <p>Removing a package is currently unsupported by Buildroot
  343. without rebuilding from scratch. This is because Buildroot doesn't
  344. keep track of which package installs what files in the
  345. <code>output/staging</code> and <code>output/target</code>
  346. directories. However, implement clean package removal is on the
  347. TODO-list of Buildroot developers.</p>
  348. <p>To rebuild a single package from scratch, the easiest way is to
  349. remove its build directory in <code>output/build</code>. Buildroot
  350. will then re-extract, re-configure, re-compile and re-install this
  351. package from scratch.</p>
  352. <p>However, if you don't want to rebuild the package completely
  353. from scratch, a better understanding of the Buildroot internals is
  354. needed. Internally, to keep track of which steps have been done
  355. and which steps remains to be done, Buildroot maintains stamps
  356. files (i.e, empty files that just tell whether this or this action
  357. has been done). The problem is that these stamps files are not
  358. uniformely named and handled by the different packages, so some
  359. understanding of the particular package is needed.</p>
  360. <p>For packages relying on the <i>autotools</i> Buildroot
  361. infrastructure (see <a href="#add_software">this section</a> for
  362. details), the following stamps files are interesting:</p>
  363. <ul>
  364. <li><code>output/build/packagename-version/.stamp_configured</code>. If
  365. removed, Buildroot will trigger the recompilation of the package
  366. from the configuration step (execution of
  367. <code>./configure</code>)</li>
  368. <li><code>output/build/packagename-version/.stamp_built</code>. If
  369. removed, Buildroot will trigger the recompilation of the package
  370. from the compilation step (execution of <code>make</code>)</li>
  371. </ul>
  372. <p>For other packages, an analysis of the specific
  373. <i>package.mk</i> file is needed. For example, the zlib Makefile
  374. looks like:</p>
  375. <pre>
  376. $(ZLIB_DIR)/.configured: $(ZLIB_DIR)/.patched
  377. (cd $(ZLIB_DIR); rm -rf config.cache; \
  378. [...]
  379. )
  380. touch $@
  381. $(ZLIB_DIR)/libz.a: $(ZLIB_DIR)/.configured
  382. $(MAKE) -C $(ZLIB_DIR) all libz.a
  383. touch -c $@
  384. </pre>
  385. <p>So, if you want to trigger the reconfiguration, you need to
  386. remove <code>output/build/zlib-version/.configured</code> and if
  387. you want to trigger only the recompilation, you need to remove
  388. <code>output/build/zlib-version/libz.a</code>.</p>
  389. <h2><a name="buildroot_innards" id="buildroot_innards"></a>How Buildroot
  390. works</h2>
  391. <p>As said above, Buildroot is basically a set of Makefiles that download,
  392. configure and compiles software with the correct options. It also includes
  393. some patches for various software, mainly the ones involved in the
  394. cross-compilation tool chain (<code>gcc</code>, <code>binutils</code> and
  395. uClibc). </p>
  396. <p>There is basically one Makefile per software, and they are named with
  397. the <code>.mk</code> extension. Makefiles are split into four
  398. sections:</p>
  399. <ul>
  400. <li><b>project</b> (in the <code>project/</code> directory) contains
  401. the Makefiles and associated files for all software related to the
  402. building several root file systems in the same buildroot tree. </li>
  403. <li><b>toolchain</b> (in the <code>toolchain/</code> directory) contains
  404. the Makefiles and associated files for all software related to the
  405. cross-compilation toolchain : <code>binutils</code>, <code>ccache</code>,
  406. <code>gcc</code>, <code>gdb</code>, <code>kernel-headers</code> and
  407. <code>uClibc</code>. </li>
  408. <li><b>package</b> (in the <code>package/</code> directory) contains the
  409. Makefiles and associated files for all user-space tools that Buildroot
  410. can compile and add to the target root filesystem. There is one
  411. sub-directory per tool. </li>
  412. <li><b>target</b> (in the <code>target</code> directory) contains the
  413. Makefiles and associated files for software related to the generation of
  414. the target root filesystem image. Four types of filesystems are supported
  415. : ext2, jffs2, cramfs and squashfs. For each of them, there's a
  416. sub-directory with the required files. There is also a
  417. <code>default/</code> directory that contains the target filesystem
  418. skeleton. </li>
  419. </ul>
  420. <p>Each directory contains at least 2 files :</p>
  421. <ul>
  422. <li><code>something.mk</code> is the Makefile that downloads, configures,
  423. compiles and installs the software <code>something</code>. </li>
  424. <li><code>Config.in</code> is a part of the configuration tool
  425. description file. It describes the option related to the current
  426. software. </li>
  427. </ul>
  428. <p>The main Makefile do the job through the following steps (once the
  429. configuration is done) :</p>
  430. <ol>
  431. <li>Create all the output directories: <code>staging</code>,
  432. <code>target</code>, <code>build</code>, <code>stamps</code>,
  433. etc. in the output directory (<code>output/</code> by default,
  434. another value can be specified using <code>O=</code>)</li>
  435. <li>Generate all the targets listed in the
  436. <code>BASE_TARGETS</code> variable. When an internal toolchain
  437. is used, it means generating the cross-compilation
  438. toolchain. When an external toolchain is used, it means checking
  439. the features of the external toolchain and importing it into the
  440. Buildroot environment.</li>
  441. <li>Generate all the targets listed in the <code>TARGETS</code>
  442. variable. This variable is filled by all the individual
  443. components Makefiles. So, generating all these targets will
  444. trigger the compilation of the userspace packages (libraries,
  445. programs), the kernel, the bootloader and the generation of the
  446. root filesystem images, depending on the configuration.</li>
  447. </ol>
  448. <h2><a name="board_support" id="board_support"></a>
  449. Creating your own board support</h2>
  450. <p>Creating your own board support in Buildroot allows you to have
  451. a convenient place to store the Busybox, uClibc, kernel
  452. configurations, your target filesystem skeleton, and a Buildroot
  453. configuration that match your project.</p>
  454. <p>Follow these steps to integrate your board in Buildroot:</p>
  455. <ol>
  456. <li>Create a new directory in <code>target/device/</code>, named
  457. after your company or organization</li>
  458. <li>Add a line <code>source
  459. "target/device/yourcompany/Config.in"</code> in
  460. <code>target/device/Config.in</code> so that your board appears
  461. in the configuration system</li>
  462. <li>In <code>target/device/yourcompany/</code>, create a
  463. directory for your project. This way, you'll be able to store
  464. several projects of your company/organization inside
  465. Buildroot.</li>
  466. <li>Create a <code>target/device/yourcompany/Config.in</code>
  467. file that looks like the following:
  468. <pre>
  469. menuconfig BR2_TARGET_COMPANY
  470. bool "Company projects"
  471. if BR2_TARGET_COMPANY
  472. config BR2_TARGET_COMPANY_PROJECT_FOOBAR
  473. bool "Support for Company project Foobar"
  474. help
  475. This option enables support for Company project Foobar
  476. endif
  477. </pre>
  478. Of course, customize the different values to match your
  479. company/organization and your project. This file will create a
  480. menu entry that contains the different projects of your
  481. company/organization.</li>
  482. <li>Create a <code>target/device/yourcompany/Makefile.in</code>
  483. file that looks like the following:
  484. <pre>
  485. ifeq ($(BR2_TARGET_COMPANY_PROJECT_FOOBAR),y)
  486. include target/device/yourcompany/project-foobar/Makefile.in
  487. endif
  488. </pre>
  489. </li>
  490. <li>Now, create the
  491. <code>target/device/yourcompany/project-foobar/Makefile.in</code>
  492. file. It is first recommended to define a
  493. <code>BOARD_PATH</code> variable set to
  494. <code>target/device/yourcompany/project-foobar</code>, as it
  495. will simplify further definitions. Then, the file might define
  496. one or several of the following variables:
  497. <ul>
  498. <li><code>TARGET_SKELETON</code> to a directory that contains
  499. the target skeleton for your project. If this variable is
  500. defined, this target skeleton will be used instead of the
  501. default one. If defined, the convention is to define it to
  502. <code>$(BOARD_PATH)/target_skeleton</code>, so that the target
  503. skeletonn is stored in the board specific directory.</li>
  504. <li><code>TARGET_DEVICE_TABLE</code> to a file that contains
  505. the target device table, i.e the list of device files (in
  506. <code>/dev/</code>) created by the root filesystem building
  507. procedure. If this variable is defined, the given device table
  508. will be used instead of the default one. If defined, the
  509. convention is to define it to
  510. <code>$(BOARD_PATH)/target_device_table.txt</code>. See
  511. <code>target/generic/device_table.txt</code> for an example
  512. file.</li>
  513. </ul>
  514. </li>
  515. <li>Then, in the
  516. <code>target/device/yourcompany/project-foobar/</code>
  517. directory, you can store configuration files for the kernel,
  518. for Busybox or uClibc.
  519. You can furthermore create one or more preconfigured configuration
  520. files, referencing those files. These config files are named
  521. <code>something_defconfig</config> and are stored in the toplevel
  522. <code>configs/</code> directory. Your users will then be able
  523. to run <code>make something_defconfig</code> and get the right
  524. configuration for your project</li>
  525. </ol>
  526. <h2><a name="using_toolchain" id="using_toolchain"></a>Using the
  527. generated toolchain outside Buildroot</h2>
  528. <p>You may want to compile your own programs or other software
  529. that are not packaged in Buildroot. In order to do this, you can
  530. use the toolchain that was generated by Buildroot. </p>
  531. <p>The toolchain generated by Buildroot by default is located in
  532. <code>output/staging/</code>. The simplest way to use it
  533. is to add <code>output/staging/usr/bin/</code> to your PATH
  534. environnement variable, and then to use
  535. <code>ARCH-linux-gcc</code>, <code>ARCH-linux-objdump</code>,
  536. <code>ARCH-linux-ld</code>, etc. </p>
  537. <p>The easiest way is of course to add the
  538. <code>output/staging/usr/bin/</code> directory to your PATH
  539. environment variable.</p>
  540. <p><b>Important</b> : do not try to move a gcc-3.x toolchain to an other
  541. directory, it won't work. There are some hardcoded paths in the
  542. <i>gcc</i> configuration. If you are using a current gcc-4.x, it
  543. is possible to relocate the toolchain, but then
  544. <code>--sysroot</code> must be passed every time the compiler is
  545. called to tell where the libraries and header files are, which
  546. might be cumbersome.</p>
  547. <p>It is also possible to generate the Buildroot toolchain in
  548. another directory than <code>build/staging</code> using the
  549. <code>Build options -&gt; Toolchain and header file
  550. location</code> option. This could be useful if the toolchain
  551. must be shared with other users.</p>
  552. <h2><a name="downloaded_packages"
  553. id="downloaded_packages"></a>Location of downloaded packages</h2>
  554. <p>It might be useful to know that the various tarballs that are
  555. downloaded by the <i>Makefiles</i> are all stored in the
  556. <code>DL_DIR</code> which by default is the <code>dl</code>
  557. directory. It's useful for example if you want to keep a complete
  558. version of Buildroot which is know to be working with the
  559. associated tarballs. This will allow you to regenerate the
  560. toolchain and the target filesystem with exactly the same
  561. versions. </p>
  562. <p>If you maintain several buildroot trees, it might be better to have
  563. a shared download location. This can be accessed by creating a symbolic link
  564. from the <code>dl</code> directory to the shared download location. </p>
  565. <p>I.E:</p>
  566. <pre>
  567. ln -s &lt;shared download location&gt; dl
  568. </pre>
  569. <p>Another way of accessing a shared download location is to
  570. create the <code>BUILDROOT_DL_DIR</code> environment variable.
  571. If this is set, then the value of DL_DIR in the project is
  572. overridden. The following line should be added to
  573. <code>&quot;~/.bashrc&quot;</code>. <p>
  574. <pre>
  575. export BUILDROOT_DL_DIR &lt;shared download location&gt;
  576. </pre>
  577. <h2><a name="external_toolchain" id="external_toolchain"></a>Using
  578. an external toolchain</h2>
  579. <p>It might be useful not to use the toolchain generated by
  580. Buildroot, for example if you already have a toolchain that is known
  581. to work for your specific CPU, or if the toolchain generation feature
  582. of Buildroot is not sufficiently flexible for you (for example if you
  583. need to generate a system with <i>glibc</i> instead of
  584. <i>uClibc</i>). Buildroot supports using an <i>external
  585. toolchain</i>.</p>
  586. <p>To enable the use of an external toolchain, go in the
  587. <code>Toolchain</code> menu, and&nbsp;:</p>
  588. <ul>
  589. <li>Select the <code>External binary toolchain</code> toolchain
  590. type</li>
  591. <li>Adjust the <code>External toolchain path</code>
  592. appropriately. It should be set to a path where a bin/ directory
  593. contains your cross-compiling tools</li>
  594. <li>Adjust the <code>External toolchain prefix</code>, so that the
  595. prefix, suffixed with <code>-gcc</code> or <code>-ld</code> will
  596. correspond to your cross-compiling tools</li>
  597. </ul>
  598. <p>If you are using an external toolchain based on <i>uClibc</i>, the
  599. <code>Core C library from the external toolchain</code> and
  600. <code>Libraries to copy from the external toolchain</code> options
  601. should already have correct values. However, if your external
  602. toolchain is based on <i>glibc</i>, you'll have to change these values
  603. according to your cross-compiling toolchain.</p>
  604. <p>To generate external toolchains, we recommend using <a
  605. href="http://ymorin.is-a-geek.org/dokuwiki/projects/crosstool">Crosstool-NG</a>.
  606. It allows to generate toolchains based on <i>uClibc</i>, <i>glibc</i>
  607. and <i>eglibc</i> for a wide range of architectures, and has good
  608. community support.</p>
  609. <h2><a name="add_software" id="add_software"></a>Extending Buildroot with
  610. more software</h2>
  611. <p>This section will only consider the case in which you want to
  612. add user-space software. </p>
  613. <h3>Package directory</h3>
  614. <p>First of all, create a directory under the <code>package</code>
  615. directory for your software, for example <code>foo</code>. </p>
  616. <h3><code>Config.in</code> file</h3>
  617. <p>Then, create a file named <code>Config.in</code>. This file
  618. will contain the portion of options description related to our
  619. <code>foo</code> software that will be used and displayed in the
  620. configuration tool. It should basically contain :</p>
  621. <pre>
  622. config BR2_PACKAGE_FOO
  623. bool "foo"
  624. help
  625. This is a comment that explains what foo is.
  626. http://foosoftware.org/foo/
  627. </pre>
  628. <p>Of course, you can add other options to configure particular
  629. things in your software. </p>
  630. <p>Finally you have to add your new <code>foo/Config.in</code> to
  631. <code>package/Config.in</code>. The files included there are
  632. <em>sorted alphabetically</em> per category and are <em>NOT</em>
  633. supposed to contain anything but the <em>bare</em> name of the package.</p>
  634. <pre>
  635. if !BR2_PACKAGE_BUSYBOX_HIDE_OTHERS
  636. source "package/procps/Config.in"
  637. endif
  638. </pre>
  639. <p><strong>Note:</strong><br>
  640. Generally all packages should live <em>directly</em> in the
  641. <code>package</code> directory to make it easier to find them.
  642. </p>
  643. <h3>The real <i>Makefile</i></h3>
  644. <p>Finally, here's the hardest part. Create a file named
  645. <code>foo.mk</code>. It will contain the <i>Makefile</i> rules that
  646. are in charge of downloading, configuring, compiling and installing
  647. the software.</p>
  648. <p>Two types of <i>Makefiles</i> can be written&nbsp;:</p>
  649. <ul>
  650. <li>Makefiles for autotools-based (autoconf, automake, etc.)
  651. softwares, are very easy to write thanks to the infrastructure
  652. available in <code>package/Makefile.autotools.in</code>.</li>
  653. <li>Makefiles for other types of packages are a little bit more
  654. complex to write.</li>
  655. </ul>
  656. <p>First, let's see how to write a <i>Makefile</i> for an
  657. autotools-based package, with an example&nbsp;:</p>
  658. <pre>
  659. <a name="ex1line1" id="ex1line1">1</a> #############################################################
  660. <a name="ex1line2" id="ex1line2">2</a> #
  661. <a name="ex1line3" id="ex1line3">3</a> # foo
  662. <a name="ex1line4" id="ex1line4">4</a> #
  663. <a name="ex1line5" id="ex1line5">5</a> #############################################################
  664. <a name="ex1line6" id="ex1line6">6</a> FOO_VERSION:=1.0
  665. <a name="ex1line7" id="ex1line7">7</a> FOO_SOURCE:=foo-$(FOO_VERSION).tar.gz
  666. <a name="ex1line8" id="ex1line8">8</a> FOO_SITE:=http://www.foosoftware.org/downloads
  667. <a name="ex1line9" id="ex1line9">9</a> FOO_INSTALL_STAGING = YES
  668. <a name="ex1line10" id="ex1line10">10</a> FOO_INSTALL_TARGET = YES
  669. <a name="ex1line11" id="ex1line11">11</a> FOO_CONF_OPT = --enable-shared
  670. <a name="ex1line12" id="ex1line12">12</a> FOO_DEPENDENCIES = libglib2 host-pkgconfig
  671. <a name="ex1line13" id="ex1line13">13</a> $(eval $(call AUTOTARGETS,package,foo))
  672. </pre>
  673. <p>On <a href="#ex1line6">line 6</a>, we declare the version of
  674. the package. On line <a href="#ex1line7">7</a> and <a
  675. href="#ex1line8">8</a>, we declare the name of the tarball and the
  676. location of the tarball on the Web. Buildroot will automatically
  677. download the tarball from this location.</p>
  678. <p>On <a href="#ex1line9">line 9</a>, we tell Buildroot to install
  679. the application to the staging directory. The staging directory,
  680. located in <code>output/staging/</code> is the directory
  681. where all the packages are installed, including their
  682. documentation, etc. By default, packages are installed in this
  683. location using the <code>make install</code> command.</p>
  684. <p>On <a href="#ex1line10">line 10</a>, we tell Buildroot to also
  685. install the application to the target directory. This directory
  686. contains what will become the root filesystem running on the
  687. target. Usually, we try not to install the documentation, and to
  688. install stripped versions of the binary. By default, packages are
  689. installed in this location using the <code>make
  690. install-strip</code> command.</p>
  691. <p>On <a href="#ex1line11">line 11</a>, we tell Buildroot to pass
  692. a custom configure option, that will be passed to the
  693. <code>./configure</code> script before configuring and building
  694. the package.</p>
  695. <p>On <a href="#ex1line12">line 12</a>, we declare our
  696. dependencies, so that they are built before the build process of
  697. our package starts.</p>
  698. <p>Finally, on line <a href="#ex1line13">line 13</a>, we invoke
  699. the <code>package/Makefile.autotools.in</code> magic to get things
  700. working.</p>
  701. <p>For more details about the available variables and options, see
  702. the comment at the top of
  703. <code>package/Makefile.autotools.in</code> and the examples in all
  704. the available packages.</p>
  705. <p>The second solution, suitable for every type of package, looks
  706. like this&nbsp;:</p>
  707. <pre>
  708. <a name="ex2line1" id="ex2line1">1</a> #############################################################
  709. <a name="ex2line2" id="ex2line2">2</a> #
  710. <a name="ex2line3" id="ex2line3">3</a> # foo
  711. <a name="ex2line4" id="ex2line4">4</a> #
  712. <a name="ex2line5" id="ex2line5">5</a> #############################################################
  713. <a name="ex2line6" id="ex2line6">6</a> FOO_VERSION:=1.0
  714. <a name="ex2line7" id="ex2line7">7</a> FOO_SOURCE:=foo-$(FOO_VERSION).tar.gz
  715. <a name="ex2line8" id="ex2line8">8</a> FOO_SITE:=http://www.foosoftware.org/downloads
  716. <a name="ex2line9" id="ex2line9">9</a> FOO_DIR:=$(BUILD_DIR)/foo-$(FOO_VERSION)
  717. <a name="ex2line10" id="ex2line10">10</a> FOO_BINARY:=foo
  718. <a name="ex2line11" id="ex2line11">11</a> FOO_TARGET_BINARY:=usr/bin/foo
  719. <a name="ex2line12" id="ex2line12">12</a>
  720. <a name="ex2line13" id="ex2line13">13</a> $(DL_DIR)/$(FOO_SOURCE):
  721. <a name="ex2line14" id="ex2line14">14</a> $(call DOWNLOAD,$(FOO_SITE),$(FOO_SOURCE))
  722. <a name="ex2line15" id="ex2line15">15</a>
  723. <a name="ex2line16" id="ex2line16">16</a> $(FOO_DIR)/.source: $(DL_DIR)/$(FOO_SOURCE)
  724. <a name="ex2line17" id="ex2line17">17</a> $(ZCAT) $(DL_DIR)/$(FOO_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
  725. <a name="ex2line18" id="ex2line18">18</a> touch $@
  726. <a name="ex2line19" id="ex2line19">19</a>
  727. <a name="ex2line20" id="ex2line20">20</a> $(FOO_DIR)/.configured: $(FOO_DIR)/.source
  728. <a name="ex2line21" id="ex2line21">21</a> (cd $(FOO_DIR); rm -rf config.cache; \
  729. <a name="ex2line22" id="ex2line22">22</a> $(TARGET_CONFIGURE_OPTS) \
  730. <a name="ex2line23" id="ex2line23">23</a> $(TARGET_CONFIGURE_ARGS) \
  731. <a name="ex2line24" id="ex2line24">24</a> ./configure \
  732. <a name="ex2line25" id="ex2line25">25</a> --target=$(GNU_TARGET_NAME) \
  733. <a name="ex2line26" id="ex2line26">26</a> --host=$(GNU_TARGET_NAME) \
  734. <a name="ex2line27" id="ex2line27">27</a> --build=$(GNU_HOST_NAME) \
  735. <a name="ex2line28" id="ex2line28">28</a> --prefix=/usr \
  736. <a name="ex2line29" id="ex2line29">29</a> --sysconfdir=/etc \
  737. <a name="ex2line30" id="ex2line30">30</a> )
  738. <a name="ex2line31" id="ex2line31">31</a> touch $@
  739. <a name="ex2line32" id="ex2line32">32</a>
  740. <a name="ex2line33" id="ex2line33">33</a> $(FOO_DIR)/$(FOO_BINARY): $(FOO_DIR)/.configured
  741. <a name="ex2line34" id="ex2line34">34</a> $(MAKE) CC=$(TARGET_CC) -C $(FOO_DIR)
  742. <a name="ex2line35" id="ex2line35">35</a>
  743. <a name="ex2line36" id="ex2line36">36</a> $(TARGET_DIR)/$(FOO_TARGET_BINARY): $(FOO_DIR)/$(FOO_BINARY)
  744. <a name="ex2line37" id="ex2line37">37</a> $(MAKE) DESTDIR=$(TARGET_DIR) -C $(FOO_DIR) install-strip
  745. <a name="ex2line38" id="ex2line38">38</a> rm -Rf $(TARGET_DIR)/usr/man
  746. <a name="ex2line39" id="ex2line39">39</a>
  747. <a name="ex2line40" id="ex2line40">40</a> foo: uclibc ncurses $(TARGET_DIR)/$(FOO_TARGET_BINARY)
  748. <a name="ex2line41" id="ex2line41">41</a>
  749. <a name="ex2line42" id="ex2line42">42</a> foo-source: $(DL_DIR)/$(FOO_SOURCE)
  750. <a name="ex2line43" id="ex2line43">43</a>
  751. <a name="ex2line44" id="ex2line44">44</a> foo-clean:
  752. <a name="ex2line45" id="ex2line45">45</a> $(MAKE) prefix=$(TARGET_DIR)/usr -C $(FOO_DIR) uninstall
  753. <a name="ex2line46" id="ex2line46">46</a> -$(MAKE) -C $(FOO_DIR) clean
  754. <a name="ex2line47" id="ex2line47">47</a>
  755. <a name="ex2line48" id="ex2line48">48</a> foo-dirclean:
  756. <a name="ex2line49" id="ex2line49">49</a> rm -rf $(FOO_DIR)
  757. <a name="ex2line50" id="ex2line50">50</a>
  758. <a name="ex2line51" id="ex2line51">51</a> #############################################################
  759. <a name="ex2line52" id="ex2line52">52</a> #
  760. <a name="ex2line53" id="ex2line53">53</a> # Toplevel Makefile options
  761. <a name="ex2line54" id="ex2line54">54</a> #
  762. <a name="ex2line55" id="ex2line55">55</a> #############################################################
  763. <a name="ex2line56" id="ex2line56">56</a> ifeq ($(BR2_PACKAGE_FOO),y)
  764. <a name="ex2line57" id="ex2line57">57</a> TARGETS+=foo
  765. <a name="ex2line58" id="ex2line58">58</a> endif
  766. </pre>
  767. <p>First of all, this <i>Makefile</i> example works for a single
  768. binary software. For other software such as libraries or more
  769. complex stuff with multiple binaries, it should be adapted. Look at
  770. the other <code>*.mk</code> files in the <code>package</code>
  771. directory. </p>
  772. <p>At lines <a href="#ex2line6">6-11</a>, a couple of useful variables are
  773. defined :</p>
  774. <ul>
  775. <li><code>FOO_VERSION</code> : The version of <i>foo</i> that
  776. should be downloaded. </li>
  777. <li><code>FOO_SOURCE</code> : The name of the tarball of
  778. <i>foo</i> on the download website of FTP site. As you can see
  779. <code>FOO_VERSION</code> is used. </li>
  780. <li><code>FOO_SITE</code> : The HTTP or FTP site from which
  781. <i>foo</i> archive is downloaded. It must include the complete
  782. path to the directory where <code>FOO_SOURCE</code> can be
  783. found. </li>
  784. <li><code>FOO_DIR</code> : The directory into which the software
  785. will be configured and compiled. Basically, it's a subdirectory
  786. of <code>BUILD_DIR</code> which is created upon decompression of
  787. the tarball. </li>
  788. <li><code>FOO_BINARY</code> : Software binary name. As said
  789. previously, this is an example for a single binary software. </li>
  790. <li><code>FOO_TARGET_BINARY</code> : The full path of the binary
  791. inside the target filesystem. </li>
  792. </ul>
  793. <p>Lines <a href="#ex2line13">13-14</a> defines a target that downloads the
  794. tarball from the remote site to the download directory
  795. (<code>DL_DIR</code>). </p>
  796. <p>Lines <a href="#ex2line16">16-18</a> defines a target and associated rules
  797. that uncompress the downloaded tarball. As you can see, this target
  798. depends on the tarball file, so that the previous target (line
  799. <a href="#ex2line13">13-14</a>) is called before executing the rules of the
  800. current target. Uncompressing is followed by <i>touching</i> a hidden file
  801. to mark the software has having been uncompressed. This trick is
  802. used everywhere in Buildroot <i>Makefile</i> to split steps
  803. (download, uncompress, configure, compile, install) while still
  804. having correct dependencies. </p>
  805. <p>Lines <a href="#ex2line20">20-31</a> defines a target and associated rules
  806. that configures the software. It depends on the previous target (the
  807. hidden <code>.source</code> file) so that we are sure the software has
  808. been uncompressed. In order to configure it, it basically runs the
  809. well-known <code>./configure</code> script. As we may be doing
  810. cross-compilation, <code>target</code>, <code>host</code> and
  811. <code>build</code> arguments are given. The prefix is also set to
  812. <code>/usr</code>, not because the software will be installed in
  813. <code>/usr</code> on your host system, but in the target
  814. filesystem. Finally it creates a <code>.configured</code> file to
  815. mark the software as configured. </p>
  816. <p>Lines <a href="#ex2line33">33-34</a> defines a target and a rule that
  817. compiles the software. This target will create the binary file in the
  818. compilation directory, and depends on the software being already
  819. configured (hence the reference to the <code>.configured</code>
  820. file). It basically runs <code>make</code> inside the source
  821. directory. </p>
  822. <p>Lines <a href="#ex2line36">36-38</a> defines a target and associated rules
  823. that install the software inside the target filesystem. It depends on the
  824. binary file in the source directory, to make sure the software has
  825. been compiled. It uses the <code>install-strip</code> target of the
  826. software <code>Makefile</code> by passing a <code>DESTDIR</code>
  827. argument, so that the <code>Makefile</code> doesn't try to install
  828. the software inside host <code>/usr</code> but inside target
  829. <code>/usr</code>. After the installation, the
  830. <code>/usr/man</code> directory inside the target filesystem is
  831. removed to save space. </p>
  832. <p>Line <a href="#ex2line40">40</a> defines the main target of the software,
  833. the one that will be eventually be used by the top level
  834. <code>Makefile</code> to download, compile, and then install
  835. this package. This target should first of all depends on all
  836. needed dependecies of the software (in our example,
  837. <i>uclibc</i> and <i>ncurses</i>), and also depend on the
  838. final binary. This last dependency will call all previous
  839. dependencies in the correct order. </p>
  840. <p>Line <a href="#ex2line42">42</a> defines a simple target that only
  841. downloads the code source. This is not used during normal operation of
  842. Buildroot, but is needed if you intend to download all required sources at
  843. once for later offline build. Note that if you add a new package providing
  844. a <code>foo-source</code> target is <i>mandatory</i> to support
  845. users that wish to do offline-builds. Furthermore it eases checking
  846. if all package-sources are downloadable. </p>
  847. <p>Lines <a href="#ex2line44">44-46</a> define a simple target to clean the
  848. software build by calling the <i>Makefiles</i> with the appropriate option.
  849. The <code>-clean</code> target should run <code>make clean</code>
  850. on $(BUILD_DIR)/package-version and MUST uninstall all files of the
  851. package from $(STAGING_DIR) and from $(TARGET_DIR). </p>
  852. <p>Lines <a href="#ex2line48">48-49</a> define a simple target to completely
  853. remove the directory in which the software was uncompressed, configured and
  854. compiled. The <code>-dirclean</code> target MUST completely rm $(BUILD_DIR)/
  855. package-version. </p>
  856. <p>Lines <a href="#ex2line51">51-58</a> adds the target <code>foo</code> to
  857. the list of targets to be compiled by Buildroot by first checking if
  858. the configuration option for this package has been enabled
  859. using the configuration tool, and if so then &quot;subscribes&quot;
  860. this package to be compiled by adding it to the TARGETS
  861. global variable. The name added to the TARGETS global
  862. variable is the name of this package's target, as defined on
  863. line <a href="#ex2line40">40</a>, which is used by Buildroot to download,
  864. compile, and then install this package. </p>
  865. <h3>Conclusion</h3>
  866. <p>As you can see, adding a software to buildroot is simply a
  867. matter of writing a <i>Makefile</i> using an already existing
  868. example and to modify it according to the compilation process of
  869. the software. </p>
  870. <p>If you package software that might be useful for other persons,
  871. don't forget to send a patch to Buildroot developers !</p>
  872. <h2><a name="links" id="links"></a>Resources</h2>
  873. <p>To learn more about Buildroot you can visit these
  874. websites:</p>
  875. <ul>
  876. <li><a href="http://www.uclibc.org/">http://www.uclibc.org/</a></li>
  877. <li><a href="http://www.busybox.net/">http://www.busybox.net/</a></li>
  878. </ul>
  879. </div>
  880. <!--
  881. <a href="http://validator.w3.org/check?uri=referer"><img
  882. border="0" height="31" width="88"
  883. src="images/valid-html401.png"
  884. alt="Valid HTML"></img></a>
  885. -->
  886. </body>
  887. </html>