The following section gives some tips and tricks on how to use efficiently
OpenWrt on a regular basis and for daily work.

\subsection{Compiling/recompiling components}

The buildroot allows you to recompile the full environment or only parts of it
like the toolchain, the kernel modules, the kernel or some packages.

For instance if you want to recompile the toolchain after you made any change to it
issue the following command:

\begin{Verbatim}
make toolchain/{clean,compile,install}
\end{Verbatim}

Which will clean, compile and install the toolchain. The command actually expands to the
following:

\begin{Verbatim}
make[1] toolchain/clean
make[2] -C toolchain/kernel-headers clean
make[2] -C toolchain/binutils clean
make[2] -C toolchain/gcc clean
make[2] -C toolchain/uClibc clean	(glibc or eglibc when chosen)
\end{Verbatim}

Of course, you could only choose to recompile one or several of the toolchain components
(binutils, kernel-headers gcc, C library) individually.

The exact same idea works for packages:

\begin{Verbatim}
make package/busybox/{clean,compile,install}
\end{Verbatim}

will clean, compile and install buysbox (if selected to be installed on the final rootfs).

Supposing that you made changes to the Linux kernel, but do not want to recompile everything,
you can recompile only the kernel modules by issuing:

\begin{Verbatim}
make target/linux/compile
\end{Verbatim}

To recompile the static part of the kernel use the following command:

\begin{Verbatim}
make target/linux/install
\end{Verbatim}

\subsection{Using quilt inside OpenWrt}

OpenWrt integrates quilt in order to ease the package, kernel and toolchain
patches maintenance when migrating over new versions of the software.

Quilt intends to replace an old workflow, where you would download the new
source file, create an original copy of it, an a working copy, then try to
apply by hand old patches and resolve conflicts manually. Additionnaly, using
quilt allows you to update and fold patches into other patches easily.

Quilt is used by default to apply Linux kernel patches, but not for the other
components (toolchain and packages).

\subsubsection{Using quilt with kernel patches}

Assuming that you have everything setup for your new kernel version:
\begin{itemize}
\item \texttt{LINUX\_VERSION} set in the target Makefile
\item config-2.6.x.y existing
\item patches-2.6.x.y containing the previous patches
\end{itemize}

Some patches are likely to fail since the vanilla kernel we are patching
received modifications so some hunks of the patches are no longer applying.
We will use quilt to get them applying cleanly again. Follow this procedure
whenever you want to upgrade the kernel using previous patches:

\begin{enumerate}
\item make target/linux/clean (removes the old version)
\item make target/linux/compile (uncompress the kernel and try to apply patches)
\item if patches failed to apply:
\item cd build\_dir/linux-target/linux-2.6.x.y
\item quilt push -a (to apply patches where quilt stopped)
\item quilt push -f (to force applying patches)
\item edit .rej files, apply the necessary changes to the files
\item remove .rej files
\item quilt refresh
\item repeat operation 3 and following until all patches have been applied
\item when all patches did apply cleanly: make target/linux/refresh
\end{enumerate}

Note that generic (target/linux/generic-2.6/linux-2.6.x/) patches can be found in 
\texttt{build\_dir/linux-target/linux-2.6.x.y/patches/generic} and platform specific
patches in \texttt{build\_dir/linux-target/linux-2.6.x.y/patches/platform}.

\subsubsection{Using quilt with packages}

As we mentionned earlier, quilt is enabled by default for kernel patches, but not for
packages. If you want to use quilt in the same way, you should set the QUILT environment
variable to 1, e.g:

\begin{Verbatim}
make package/buysbox/{clean,compile} QUILT=1
\end{Verbatim}

Will generate the patch series file and allow you to update patches just like we described
before in the kernel case. Note that once all patches apply cleanly you should refresh them
as well using the following command:

\begin{Verbatim}
make package/buysbox/refresh QUILT=1
\end{Verbatim}
ed5'>plain</a>)
<table summary='blob content' class='blob'>
<tr><td class='linenumbers'><pre><a id='n1' href='#n1'>1</a>
<a id='n2' href='#n2'>2</a>
<a id='n3' href='#n3'>3</a>
<a id='n4' href='#n4'>4</a>
<a id='n5' href='#n5'>5</a>
<a id='n6' href='#n6'>6</a>
<a id='n7' href='#n7'>7</a>
<a id='n8' href='#n8'>8</a>
<a id='n9' href='#n9'>9</a>
<a id='n10' href='#n10'>10</a>
<a id='n11' href='#n11'>11</a>
<a id='n12' href='#n12'>12</a>
<a id='n13' href='#n13'>13</a>
<a id='n14' href='#n14'>14</a>
<a id='n15' href='#n15'>15</a>
<a id='n16' href='#n16'>16</a>
<a id='n17' href='#n17'>17</a>
<a id='n18' href='#n18'>18</a>
<a id='n19' href='#n19'>19</a>
<a id='n20' href='#n20'>20</a>
<a id='n21' href='#n21'>21</a>
<a id='n22' href='#n22'>22</a>
<a id='n23' href='#n23'>23</a>
<a id='n24' href='#n24'>24</a>
<a id='n25' href='#n25'>25</a>
<a id='n26' href='#n26'>26</a>
<a id='n27' href='#n27'>27</a>
<a id='n28' href='#n28'>28</a>
<a id='n29' href='#n29'>29</a>
<a id='n30' href='#n30'>30</a>
</pre></td>
<td class='lines'><pre><code>